Skip to content

Commit db83e07

Browse files
committed
feat(editor): implement Ctrl+Home and Ctrl+End
The necessary feature is actually already there.
1 parent c0e54ba commit db83e07

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -501,8 +501,8 @@ It has the following key bindings:
501501
- **PgDn**/**Ctrl+F**: Page down
502502
- **Ctrl+←**/**Alt+B**: Move to the start of the word
503503
- **Ctrl+→**/**Alt-F**: Move to the end of the word
504-
<!-- - **Ctrl+Home**: Move to the start of the text -->
505-
<!-- - **Ctrl+End**: Move to the end of the text -->
504+
- **Ctrl+Home**: Move to the start of the text
505+
- **Ctrl+End**: Move to the end of the text
506506

507507
#### Editing
508508

editor/editor.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,15 +97,14 @@ func Edit(title, initial string, save, mouse bool) (string, error) {
9797

9898
case tcell.KeyHome:
9999
if event.Modifiers()&tcell.ModCtrl != 0 {
100-
// Go to the beginning of the buffer.
101-
// Not implemented until upstream implements it.
100+
textArea.Select(0, 0)
102101
return nil
103102
}
104103

105104
case tcell.KeyEnd:
106105
if event.Modifiers()&tcell.ModCtrl != 0 {
107-
// Go to the end of the buffer.
108-
// Not implemented until upstream implements it.
106+
length := textArea.GetTextLength()
107+
textArea.Select(length, length)
109108
return nil
110109
}
111110
}

0 commit comments

Comments
 (0)