Commit d3110e3
authored
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.1 parent c4ec868 commit d3110e3
1 file changed
+41
-38
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
80 | | - | |
| 80 | + | |
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
| |||
109 | 109 | | |
110 | 110 | | |
111 | 111 | | |
112 | | - | |
| 112 | + | |
113 | 113 | | |
114 | 114 | | |
115 | 115 | | |
| 116 | + | |
116 | 117 | | |
117 | 118 | | |
118 | 119 | | |
| |||
138 | 139 | | |
139 | 140 | | |
140 | 141 | | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
145 | 145 | | |
146 | 146 | | |
147 | 147 | | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | 148 | | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
163 | 152 | | |
164 | 153 | | |
165 | 154 | | |
| |||
189 | 178 | | |
190 | 179 | | |
191 | 180 | | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
192 | 194 | | |
193 | 195 | | |
194 | 196 | | |
| |||
239 | 241 | | |
240 | 242 | | |
241 | 243 | | |
242 | | - | |
243 | 244 | | |
244 | 245 | | |
245 | 246 | | |
| |||
277 | 278 | | |
278 | 279 | | |
279 | 280 | | |
280 | | - | |
281 | | - | |
| 281 | + | |
| 282 | + | |
282 | 283 | | |
283 | 284 | | |
| 285 | + | |
284 | 286 | | |
285 | 287 | | |
286 | 288 | | |
| |||
310 | 312 | | |
311 | 313 | | |
312 | 314 | | |
313 | | - | |
314 | | - | |
| 315 | + | |
| 316 | + | |
315 | 317 | | |
316 | 318 | | |
317 | | - | |
318 | | - | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
319 | 322 | | |
320 | | - | |
321 | 323 | | |
322 | | - | |
| 324 | + | |
323 | 325 | | |
324 | | - | |
| 326 | + | |
325 | 327 | | |
326 | 328 | | |
327 | 329 | | |
328 | | - | |
329 | | - | |
330 | | - | |
331 | | - | |
332 | | - | |
| 330 | + | |
333 | 331 | | |
334 | 332 | | |
335 | 333 | | |
336 | 334 | | |
337 | | - | |
| 335 | + | |
338 | 336 | | |
| 337 | + | |
339 | 338 | | |
340 | 339 | | |
341 | 340 | | |
| |||
345 | 344 | | |
346 | 345 | | |
347 | 346 | | |
348 | | - | |
| 347 | + | |
| 348 | + | |
349 | 349 | | |
| 350 | + | |
350 | 351 | | |
351 | 352 | | |
352 | 353 | | |
| |||
359 | 360 | | |
360 | 361 | | |
361 | 362 | | |
362 | | - | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
363 | 366 | | |
364 | 367 | | |
365 | 368 | | |
| |||
0 commit comments