mirror of https://github.com/Hilbis/Hilbish
fix: make delete word function accurately
parent
ab4fa85c26
commit
d3e043ac07
|
@ -182,3 +182,27 @@ func (rl *Instance) deleteToEnd() {
|
||||||
// Keep everything before the cursor
|
// Keep everything before the cursor
|
||||||
rl.line = rl.line[:rl.pos]
|
rl.line = rl.line[:rl.pos]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (rl *Instance) emacsForwardWord(tokeniser tokeniser) (adjust int) {
|
||||||
|
// when emacs has more specific stuff, move this in a file with then
|
||||||
|
split, index, pos := tokeniser(rl.line, rl.pos)
|
||||||
|
if len(split) == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
word := rTrimWhiteSpace(split[index])
|
||||||
|
|
||||||
|
switch {
|
||||||
|
case len(split) == 0:
|
||||||
|
return
|
||||||
|
case index == len(split)-1 && pos >= len(word)-1:
|
||||||
|
return
|
||||||
|
case pos >= len(word)-1:
|
||||||
|
word = rTrimWhiteSpace(split[index+1])
|
||||||
|
adjust = len(split[index]) - pos
|
||||||
|
adjust += len(word)
|
||||||
|
default:
|
||||||
|
adjust = len(word) - pos
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
|
@ -785,8 +785,9 @@ func (rl *Instance) escapeSeq(r []rune) {
|
||||||
if rl.modeViMode != VimInsert {
|
if rl.modeViMode != VimInsert {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
rl.saveToRegister(rl.viJumpW(tokeniseLine))
|
rl.saveToRegister(rl.emacsForwardWord(tokeniseLine))
|
||||||
rl.viDeleteByAdjust(rl.viJumpW(tokeniseLine))
|
// vi delete, emacs forward, funny huh
|
||||||
|
rl.viDeleteByAdjust(rl.emacsForwardWord(tokeniseLine))
|
||||||
rl.updateHelpers()
|
rl.updateHelpers()
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Reference in New Issue