add ic_enable_space_completes: optionally accept the selected completion with a space - #46
Open
DrStoune wants to merge 1 commit into
Open
add ic_enable_space_completes: optionally accept the selected completion with a space#46DrStoune wants to merge 1 commit into
DrStoune wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
add
ic_enable_space_completes: optionally accept the selected completion with a spaceProblem
In the completion menu, when an entry is selected (and shown as a preview),
typing a printable character accepts the selection and keeps typing — the
!code_is_virt_key(c)branch inedit_completion_menu. A space, however, isclassified as a virtual key (
code_is_virt_keyisKEY_NO_MODS(c) <= 0x20,and space is 0x20), so it falls through to the default branch instead: the
menu closes, the selection is silently discarded, and a plain space is
inserted.
Since the preview shows the completion as if it were already inserted, having
it vanish on space is surprising — space is the most common "accept this word
and keep typing" key on a command line. zsh's
menuselectand the fish pagerboth accept the selected entry on space.
Change
A new opt-in toggle, following the existing
ic_enable_*pattern:Default is off, so behavior is unchanged unless the application asks for
it. When enabled, a space with an entry selected accepts the entry and then
inserts the space after it (the space is pushed back like any other passthrough
key). The new branch mirrors the
selected >= 0guard of the enter/right/endbranch, so it behaves consistently in both preview and no-preview modes.
23 added lines, no lines removed: one flag in
ic_env_t, one branch inedit_completion_menu, the setter, the doc comment, and a readme row.Testing
gcc -Wall -Wextra -c src/isocline.c— no new warnings vs. main (27 before,27 after).
completer offering
apple/banana/cherry, key sequenceTABTABSPACEXENTER:LINE=[ X]— selection discarded, identical to mainLINE=[apple X]— selection accepted, space inserted after