Skip to content

fix: deleteToLineStart joins with previous line when cursor at col 0#938

Merged
simonklee merged 3 commits intoanomalyco:mainfrom
fredsh2k:fix-delete-to-line-start
Apr 10, 2026
Merged

fix: deleteToLineStart joins with previous line when cursor at col 0#938
simonklee merged 3 commits intoanomalyco:mainfrom
fredsh2k:fix-delete-to-line-start

Conversation

@fredsh2k
Copy link
Copy Markdown
Contributor

@fredsh2k fredsh2k commented Apr 9, 2026

Summary

  • Fixes deleteToLineStart() doing nothing when the cursor is at column 0 with row > 0
  • When cursor is at col 0, calls editBuffer.deleteCharBackward() to remove the newline and join with the previous line

Details

EditBufferRenderable.deleteToLineStart() only deletes when cursor.col > 0. After clearing a line's content, the cursor sits at col 0 and subsequent calls are no-ops. This makes repeated Ctrl+U presses get stuck instead of continuing to delete line-by-line upward.

The fix adds an else if (cursor.row > 0) branch that calls editBuffer.deleteCharBackward() to remove the newline character, matching the behavior users expect from terminals and editors.

Tests

Added 4 new tests in Textarea.editing.test.ts:

  • Delete to line start from middle of line (existing behavior)
  • Join with previous line when at col 0
  • No-op when at row 0 col 0
  • Repeated deleteToLineStart across multiple lines

Closes #937

@fredsh2k fredsh2k marked this pull request as ready for review April 9, 2026 10:15
@simonklee simonklee enabled auto-merge (squash) April 10, 2026 15:53
@simonklee simonklee merged commit 9079f36 into anomalyco:main Apr 10, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

deleteToLineStart() does nothing when cursor is at column 0

2 participants