mirror of
https://github.com/earendil-works/pi.git
synced 2026-06-18 15:54:04 +08:00
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:
committed by
GitHub
Unverified
parent
4058346a64
commit
ab37d661af
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user