Skip to content

deleteToLineStart() does nothing when cursor is at column 0 #937

@fredsh2k

Description

@fredsh2k

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions