feat: control k to delete the rest of the line (#128)

Co-authored-by: Renzix <DanielDeBruno@renzix.com>
pull/131/head
Renzix 2022-03-26 23:43:30 -04:00 committed by GitHub
parent 0aba60b5de
commit 61c9e12a4a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 0 deletions

View File

@ -176,3 +176,9 @@ func (rl *Instance) deleteToBeginning() {
rl.line = rl.line[rl.pos:]
rl.pos = 0
}
func (rl *Instance) deleteToEnd() {
rl.resetVirtualComp(false)
// Keep everything before the cursor
rl.line = rl.line[:rl.pos]
}

View File

@ -189,6 +189,16 @@ func (rl *Instance) Readline() (string, error) {
rl.resetHelpers()
rl.updateHelpers()
case charCtrlK:
if rl.modeTabCompletion {
rl.resetVirtualComp(true)
}
// Delete everything after the cursor position
rl.saveBufToRegister(rl.line[rl.pos:])
rl.deleteToEnd()
rl.resetHelpers()
rl.updateHelpers()
case charBackspace, charBackspace2:
// When currently in history completion, we refresh and automatically
// insert the first (filtered) candidate, virtually