summaryrefslogtreecommitdiff
path: root/ui/editor.go
diff options
context:
space:
mode:
authorHubert Hirtz <hubert@hirtz.pm>2021-03-04 17:59:35 +0100
committerHubert Hirtz <hubert@hirtz.pm>2021-03-04 17:59:35 +0100
commit2cb8cf55ea1edb7be6142ae4e9b2a514a2e3173d (patch)
tree1a0854b442651f333a113f859c071a6ff52f6f6b /ui/editor.go
parentDo not use dim styles on the buffer list (diff)
Support cycling backward in auto-completions
Diffstat (limited to 'ui/editor.go')
-rw-r--r--ui/editor.go8
1 files changed, 3 insertions, 5 deletions
diff --git a/ui/editor.go b/ui/editor.go
index 16e9532..66774e0 100644
--- a/ui/editor.go
+++ b/ui/editor.go
@@ -212,23 +212,21 @@ func (e *Editor) Down() {
e.End()
}
-func (e *Editor) AutoComplete() (ok bool) {
+func (e *Editor) AutoComplete(offset int) (ok bool) {
if e.autoCache == nil {
e.autoCache = e.autoComplete(e.cursorIdx, e.text[e.lineIdx])
- if e.autoCache == nil {
- return false
- }
if len(e.autoCache) == 0 {
e.autoCache = nil
return false
}
e.autoCacheIdx = 0
+ } else {
+ e.autoCacheIdx = (e.autoCacheIdx + len(e.autoCache) + offset) % len(e.autoCache)
}
e.text[e.lineIdx] = e.autoCache[e.autoCacheIdx].Text
e.cursorIdx = e.autoCache[e.autoCacheIdx].CursorIdx
e.computeTextWidth()
- e.autoCacheIdx = (e.autoCacheIdx + 1) % len(e.autoCache)
if len(e.textWidth) <= e.offsetIdx {
e.offsetIdx = 0
}