deleteToLineStart() does nothing when cursor is at column 0
Description
EditBufferRenderable.deleteToLineStart() only deletes when cursor.col > 0. When the cursor is already at column 0 (e.g. after a previous delete-to-line-start cleared the line content), pressing Ctrl+U again does nothing. It should join with the previous line by removing the newline character, similar to how deleteCharBackward() works at column 0.
Current behavior
line 1
line 2
|line 3 <- cursor at col 0, row 2
Pressing Ctrl+U → nothing happens (stuck).
Expected behavior
Pressing Ctrl+U at col 0 should delete the newline before the cursor, joining with the previous line:
line 1
line 2|line 3 <- cursor now at end of "line 2"
Root cause
In EditBufferRenderable.deleteToLineStart():
deleteToLineStart() {
const cursor = this.editorView.getCursor();
if (cursor.col > 0) { // <-- skips when col === 0
this.editBuffer.deleteRange(cursor.row, 0, cursor.row, cursor.col);
}
this.requestRender();
return true;
}
The cursor.col > 0 guard prevents any action when the cursor is at the start of a line. When col === 0 and row > 0, it should delete the newline to join with the previous line.
It should join with the previous line by removing the newline character
This is a behavior change. What do you think @kommander?
Ctrl+U at col 0 moves to the prev line.
@simonklee that PR makes sense to me and looks fine.
Yeh, i tested it and it works fine. it was mostly about the behavior, if we want that.