feat(tui): jump to line start/end when pressing up/down at boundaries (#1050)

When cursor is on the first visual line and up is pressed, jump to
start of line instead of doing nothing. When cursor is on the last
visual line and down is pressed, jump to end of line instead of doing
nothing. This matches standard behavior in most native text inputs.
This commit is contained in:
4h9fbZ 2026-01-30 02:42:24 +01:00 committed by GitHub
parent 4058346a64
commit ab37d661af
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -669,6 +669,9 @@ export class Editor implements Component, Focusable {
this.navigateHistory(-1);
} else if (this.historyIndex > -1 && this.isOnFirstVisualLine()) {
this.navigateHistory(-1);
} else if (this.isOnFirstVisualLine()) {
// Already at top - jump to start of line
this.moveToLineStart();
} else {
this.moveCursor(-1, 0);
}
@ -677,6 +680,9 @@ export class Editor implements Component, Focusable {
if (kb.matches(data, "cursorDown")) {
if (this.historyIndex > -1 && this.isOnLastVisualLine()) {
this.navigateHistory(1);
} else if (this.isOnLastVisualLine()) {
// Already at bottom - jump to end of line
this.moveToLineEnd();
} else {
this.moveCursor(1, 0);
}