diff options
| author | Johannes Altmanninger <aclopte@gmail.com> | 2022-07-19 12:58:14 +0200 |
|---|---|---|
| committer | Johannes Altmanninger <aclopte@gmail.com> | 2022-07-30 22:17:32 +0200 |
| commit | 031de6d28ca7279989d431c2e0225803c9389887 (patch) | |
| tree | 2cf4c091d46cbf5ccca6bd38dd435436e9adaa65 /src/shared_string.cc | |
| parent | 0b5dcf062fd9af87428d599d26acad2dcecb3d30 (diff) | |
Use menu behavior for completing builtins where appropriate
This allows to select completions without pressing Tab.
There are two different obvious ways to add the menu bit.
1. When creating the "Completions" object, pass the
Completions::Flags::Menu parameter.
2. If there is a completer function like "complete_scope", wrap
it, e.g. "menu(complete_scope)".
I have settled on always using 2 if there is a completer function
and 1 otherwise.
The advantage of 2 over 1 is that it allows to use the completer
function in a context where we don't want the menu behavior
(e.g. "complete-command").
---
Now the only* completion type where we usually don't use menu behavior
is file completion. Unfortunately, menu behavior has poor interaction
with directories' trailing slashes. Consider this (contrived) example:
define-command ls -docstring "list directory contents" -params .. %{
echo -- %sh{ls "$@"}
}
complete-command -menu ls file
Run ":ls kakoun<ret>". The prompt expands to ":ls kakoune/"
before executing. Next, run ":<c-p>". This recalls ":ls kakoune/"
and immediately selects the first completion, so on validation,
the command will be ":ls kakoune/colors/", which is weird.
[*] Also, expansions like %val{bufname} also don't use menu
behavior. It wouldn't add value since validation doesn't add a
closing delimiter. I have an experimental patch that adds closing
delimiters automatically but I'm not sure if that's the right
direction.
Diffstat (limited to 'src/shared_string.cc')
0 files changed, 0 insertions, 0 deletions
