You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: use a transient map to avoid overlay keymaps issues (#4676)
* fix: Use overriding-terminal-local-map instead of trusting the overlay keymap
Despite having higher priority, the inline completion overlay keymap may not
be active when other overlays around point also define a keymap.
This can be observed with smartparens -- upon inserting a pair, smartparens
creates an overlay to track the inserted pair. This overlay has a keymap
binging only `C-g`. Nonetheless, if the user triggers inline completions
inside a recently inserted pair such as the example below (cursor at `|')
value = [
|
]
then the inline completion shown at `|' would now have its keymap active.
In that case, pressing `C-g' once would call the smartparens function that
removes the current overlay, and afterwards the inline completion overlay
would be active.
This results in weird behaviours -- e.g. pressing `C-g' once does not cancel
the suggestion, but twice does; Pressing `C-<return>' results in a "C-<return>
is undefined" message, etc.
This change updates the inline completion mechanism to use
`overriding-terminal-local-map`. This ensures that the inline completion
keymap is active when the overlay is shown (see
https://www.gnu.org/software/emacs/manual/html_node/elisp/Searching-Keymaps.html).
Since the inline completion keymap binds `[t]' to a "hide and execute whatever
command was bound before", we end up with the expected behaviour of the
overlay keymap.
* feat: use unread-command-events when cancelling inline completion
When the inline completion handles `[t]`, we want it to tear down the
completion UI and act as if nothing had happened.
That works fine for single key events (escape, a-z (self-insert-command),
etc.).
Trying to use multi-key commands, on the other hand fails: If `C-x w q` is
bound (e.g. `quit-restore-window`), starting the key combination when inline
completion is active would result in cancel-with-input function being called
only with `C-x` as last-key. If we lookup C-x , it's not bound to a command,
so we do not execute anything. The user then proceeds to type `w q` and ends
up inserting the text "wq" instead of quitting the window.
This fixes that by using the unread-command-events -- that basically leaves
some input to be handled by the next iteration of the event loop.
As a result, we can now successfully call complex key combinations when the
inline completion is active.
0 commit comments