Skip to content

Pressing <space> in prompt should not select completions #5411

@ficd0

Description

@ficd0

TL;DR

Pressing <space> in prompt mode when the prompt supplies completions applies
the selected completion before inserting the space. This isn't documented in
:doc keys, and seems a case of Kakoune trying to be too smart. I propose
removing this behavior; <space> should consistently just insert spaces, and
users can press <tab> if they wish to apply a completion.

Explanation

Like others, I really like using Kakoune's fuzzy completions in the prompt,
especially for tasks like selecting files to open, buffers to delete, etc.
However, one "fuzzy finding" behavior we're used to from tools like fzf is the
ability to press <space> in our queries. For example, consider this prompt:

prompt -menu -shell-script-candidates 'fd . --exclude ".git" --exclude "*.pdf" --hidden --type f --follow --ignore-file=.kakignore' open: %{
    edit -existing %val{text}
}

Suppose the file I'm trying to get to is autoload/filetype/markdown.kak. I
tend to break this down into logical units au, fi, ma, etc. And when
typing my query, it feels natural to separate them by a space, in essence typing
au fi ma<tab><ret> to select the completion and open the file.

However, for prompts that supply completions, pressing <space> always applies
the top completion first; similar to pressing <tab><space>. In the file
picking example above, it's not as big of a deal, but this can turn out to be a
real UX concern with plugins like kak-lsp, which uses prompt and completion
for features like "workspace symbol selection" -- as it stands, one cannot
include spaces in these queries.

I propose that pressing <space> should not automatically apply the
completion like this. To me, this feels like a case of Kakoune trying to be
"smart"; but ends up stepping on the toes of someone that just wanted to type a
literal space.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions