fix(readline): home and end buttons not putting the cursor in the right place

pull/143/head
TorchedSammy 2022-04-18 16:04:56 -04:00
parent 4e8aa7ed1d
commit 1e48a3e03d
Signed by: sammyette
GPG Key ID: 904FC49417B44DCD
1 changed files with 6 additions and 10 deletions

View File

@ -689,8 +689,7 @@ func (rl *Instance) escapeSeq(r []rune) {
} }
if (rl.modeViMode == VimInsert && rl.pos < len(rl.line)) || if (rl.modeViMode == VimInsert && rl.pos < len(rl.line)) ||
(rl.modeViMode != VimInsert && rl.pos < len(rl.line)-1) { (rl.modeViMode != VimInsert && rl.pos < len(rl.line)-1) {
moveCursorForwards(1) rl.moveCursorByAdjust(1)
rl.pos++
} }
rl.updateHelpers() rl.updateHelpers()
rl.viUndoSkipAppend = true rl.viUndoSkipAppend = true
@ -705,10 +704,7 @@ func (rl *Instance) escapeSeq(r []rune) {
rl.renderHelpers() rl.renderHelpers()
return return
} }
if rl.pos > 0 { rl.moveCursorByAdjust(-1)
moveCursorBackwards(1)
rl.pos--
}
rl.viUndoSkipAppend = true rl.viUndoSkipAppend = true
rl.updateHelpers() rl.updateHelpers()
@ -749,16 +745,16 @@ func (rl *Instance) escapeSeq(r []rune) {
if rl.modeTabCompletion { if rl.modeTabCompletion {
return return
} }
moveCursorBackwards(rl.pos) rl.moveCursorByAdjust(-rl.pos)
rl.pos = 0 rl.updateHelpers()
rl.viUndoSkipAppend = true rl.viUndoSkipAppend = true
case seqEnd, seqEndSc: case seqEnd, seqEndSc:
if rl.modeTabCompletion { if rl.modeTabCompletion {
return return
} }
moveCursorForwards(len(rl.line) - rl.pos) rl.moveCursorByAdjust(len(rl.line) - rl.pos)
rl.pos = len(rl.line) rl.updateHelpers()
rl.viUndoSkipAppend = true rl.viUndoSkipAppend = true
case seqAltB: case seqAltB: