Skip to content

Commit

Permalink
Fixes a minibuffer/cmdline completion bug
Browse files Browse the repository at this point in the history
If the user opened the cmdline and typed "help ", four completions would
be correctly offered for help subarguments. But if the user then hit
tab, the cmdline expanded incorrectly to "help help".
  • Loading branch information
gcla committed Jun 19, 2021
1 parent 49fa930 commit ee6936d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
5 changes: 0 additions & 5 deletions ui/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -1353,11 +1353,6 @@ func lastLineMode(app gowid.IApp) {
return nil
}))

MiniBuffer.Register("help", minibufferFn(func(gowid.IApp, ...string) error {
OpenTemplatedDialog(appView, "UIHelp", app)
return nil
}))

MiniBuffer.Register("no-theme", minibufferFn(func(app gowid.IApp, s ...string) error {
mode := theme.Mode(app.GetColorMode()).String() // more concise
termshark.DeleteConf(fmt.Sprintf("main.theme-%s", mode))
Expand Down
12 changes: 8 additions & 4 deletions widgets/minibuffer/minibuffer.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,10 +294,14 @@ func (w *Widget) handleSelection(keyIsEnter bool, app gowid.IApp) {
extraPrefix += string(c)
}
longestPrefixPartial := partials[selectedIdx]
// e.g. "cl" + "ear-" from ["clear-packets", "clear-filter"]
longestPrefixPartial.qword = words[len(words)-1] + extraPrefix
w.ed.SetText(longestPrefixPartial.Line(), app)
w.ed.SetCursorPos(longestPrefixPartial.CursorPos(), app)
// if the user types e.g. "help " then hits tab, extraPrefix will be "" (no characters typed
// to start selection of next argument) so don't complete.
if extraPrefix != "" {
// e.g. "cl" + "ear-" from ["clear-packets", "clear-filter"]
longestPrefixPartial.qword = words[len(words)-1] + extraPrefix
w.ed.SetText(longestPrefixPartial.Line(), app)
w.ed.SetCursorPos(longestPrefixPartial.CursorPos(), app)
}
}
}
}
Expand Down

0 comments on commit ee6936d

Please sign in to comment.