Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
HOME/END not working when selection exists
  • Loading branch information
richardwilkes committed Dec 17, 2022
1 parent 0da7195 commit c41dadd
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions field.go
Original file line number Diff line number Diff line change
Expand Up @@ -592,10 +592,12 @@ func (f *Field) DefaultRuneTyped(ch rune) bool {
func (f *Field) handleHome(lineOnly, extend bool) {
switch {
case lineOnly:
var start int
if f.selectionStart == 0 || f.runes[f.selectionStart-1] == '\n' {
return
start = f.findPrevLineBreak(f.selectionStart + 1)
} else {
start = f.findPrevLineBreak(f.selectionStart)
}
start := f.findPrevLineBreak(f.selectionStart)
if start != 0 {
start++
}
Expand All @@ -614,10 +616,12 @@ func (f *Field) handleHome(lineOnly, extend bool) {
func (f *Field) handleEnd(lineOnly, extend bool) {
switch {
case lineOnly:
var end int
if f.selectionEnd == len(f.runes) || f.runes[f.selectionEnd] == '\n' {
return
end = f.findNextLineBreak(f.selectionEnd - 1)
} else {
end = f.findNextLineBreak(f.selectionEnd)
}
end := f.findNextLineBreak(f.selectionEnd)
if extend {
f.setSelection(f.selectionStart, end, f.selectionStart)
} else {
Expand Down

0 comments on commit c41dadd

Please sign in to comment.