Commit 934b84d
committed
feat: <Esc> dismisses, and it counts
There was no discoverable way to say no. `<C-]>` existed and was bound, but it
appeared in exactly one un-highlighted README table row, never beside a
suggestion, and users concluded dismissal was unimplemented.
The fix is not a new keymap. `<Esc>` already dismissed — InsertLeave clears the
suggestion — it just did so silently, filing nothing, so the identical edit came
straight back on re-entering insert. Now InsertLeave records the rejection, and
the hint advertises the key that was working all along:
⟪neocursor · <Tab> accept · <Esc> dismiss⟫
No insert-mode <Esc> mapping is installed, deliberately. In VS Code, Escape is a
free key; in neovim it is the mode transition, and a conditional Esc would make
macros non-deterministic (whether a ghost is showing depends on a debounced
network reply), would clobber im-select and snippet mappings, and has no clean
fallthrough — feedkeys with "n" skips the mapping the user actually wanted,
with "m" re-enters ours. Advertising behaviour that already exists costs none of
that. <C-]> stays as the dismiss-without-leaving-insert variant; it is the key
copilot.vim, copilot.lua and avante.nvim all use.
This also happens to be what Cursor does under a vim layer. Their
handleKeyDownForCppKeys is a raw document keydown listener, not a registered
keybinding, and the suggestion branch never calls preventDefault — only the
auto-import branch does. So in Cursor + vscode-neovim, Escape dismisses the
suggestion AND propagates to neovim, which leaves insert. Both happen. Their
tiering collapses to one tier for vim users by accident.
Dismissal is tiered where it can be. Cursor's first Escape files the suggestion
as rejected and deliberately keeps the jump target alive (their handler calls
maybeShowHintLineWidget immediately after); only a second press, with nothing
showing, reaches clearCursorPrediction. reject_suggestion() and
reject_prediction() split accordingly, and <C-]> walks them in that order.
Collapsing the two — which the first draft of this change did — mutes jump
targets the user never said no to, for the 30s pred_rejects TTL, after two
ordinary trips through normal mode. flow_spec round 4 caught it.
Ports Cursor's hasRejectedTooManySuggestions, the churn gate the per-suggestion
ledger cannot express: HEURISTIC_SUGGESTING_RECENTLY_REJECTED_EDIT catches the
model repeating itself, this catches it being wrong in a new way every time.
Past the budget the passive triggers stop firing — entering insert, moving to
another line — while typing still asks. That split is Cursor's: their
content-change and linter-error paths never consult the gate. Accepting anything
refills it, as does leaving the buffer (their onDidBlurEditorText; merely
leaving insert is not the analogue, that happens constantly here).
One deliberate divergence. Cursor increments on every clearSuggestions(); this
counts dismissals instead. Their suggestion survives typing via
isOnShortestEditPath, ours only does for inline ghosts — a diff is dropped and
refetched per keystroke, so counting clears would mute after ~20 characters
rather than ~20 ignored suggestions.
maxNumberOfClearedSuggestionsSinceLastAccept now comes down with the rest of
CppConfig; the live backend returns 20, which is what the hardcoded default was
set to independently. :NeocursorLog shows the tally and flips to MUTED at the
threshold.1 parent 19044b3 commit 934b84d
4 files changed
Lines changed: 114 additions & 23 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
102 | | - | |
| 102 | + | |
| 103 | + | |
103 | 104 | | |
104 | 105 | | |
105 | 106 | | |
| |||
124 | 125 | | |
125 | 126 | | |
126 | 127 | | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
127 | 146 | | |
128 | 147 | | |
129 | 148 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
94 | 94 | | |
95 | 95 | | |
96 | 96 | | |
97 | | - | |
| 97 | + | |
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
| |||
109 | 109 | | |
110 | 110 | | |
111 | 111 | | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
116 | 117 | | |
117 | 118 | | |
118 | 119 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
31 | 34 | | |
32 | 35 | | |
33 | 36 | | |
| |||
150 | 153 | | |
151 | 154 | | |
152 | 155 | | |
153 | | - | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
154 | 160 | | |
155 | 161 | | |
156 | 162 | | |
| |||
182 | 188 | | |
183 | 189 | | |
184 | 190 | | |
| 191 | + | |
185 | 192 | | |
186 | 193 | | |
187 | 194 | | |
| |||
249 | 256 | | |
250 | 257 | | |
251 | 258 | | |
252 | | - | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
253 | 265 | | |
254 | 266 | | |
255 | 267 | | |
| |||
260 | 272 | | |
261 | 273 | | |
262 | 274 | | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
263 | 278 | | |
264 | 279 | | |
265 | 280 | | |
| |||
330 | 345 | | |
331 | 346 | | |
332 | 347 | | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
333 | 394 | | |
334 | 395 | | |
335 | 396 | | |
| |||
998 | 1059 | | |
999 | 1060 | | |
1000 | 1061 | | |
| 1062 | + | |
| 1063 | + | |
| 1064 | + | |
1001 | 1065 | | |
1002 | | - | |
1003 | | - | |
1004 | | - | |
1005 | | - | |
1006 | | - | |
1007 | | - | |
1008 | | - | |
1009 | | - | |
1010 | | - | |
1011 | | - | |
1012 | | - | |
1013 | | - | |
| 1066 | + | |
| 1067 | + | |
| 1068 | + | |
| 1069 | + | |
| 1070 | + | |
1014 | 1071 | | |
1015 | 1072 | | |
1016 | 1073 | | |
| |||
1059 | 1116 | | |
1060 | 1117 | | |
1061 | 1118 | | |
| 1119 | + | |
1062 | 1120 | | |
1063 | 1121 | | |
1064 | 1122 | | |
| |||
1107 | 1165 | | |
1108 | 1166 | | |
1109 | 1167 | | |
1110 | | - | |
| 1168 | + | |
1111 | 1169 | | |
1112 | 1170 | | |
1113 | 1171 | | |
| |||
1118 | 1176 | | |
1119 | 1177 | | |
1120 | 1178 | | |
1121 | | - | |
| 1179 | + | |
| 1180 | + | |
1122 | 1181 | | |
1123 | 1182 | | |
1124 | 1183 | | |
1125 | 1184 | | |
1126 | 1185 | | |
1127 | 1186 | | |
1128 | 1187 | | |
1129 | | - | |
| 1188 | + | |
| 1189 | + | |
| 1190 | + | |
| 1191 | + | |
| 1192 | + | |
| 1193 | + | |
1130 | 1194 | | |
1131 | 1195 | | |
| 1196 | + | |
| 1197 | + | |
| 1198 | + | |
| 1199 | + | |
1132 | 1200 | | |
1133 | 1201 | | |
1134 | 1202 | | |
| |||
1181 | 1249 | | |
1182 | 1250 | | |
1183 | 1251 | | |
| 1252 | + | |
| 1253 | + | |
1184 | 1254 | | |
1185 | 1255 | | |
1186 | 1256 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
326 | 326 | | |
327 | 327 | | |
328 | 328 | | |
| 329 | + | |
329 | 330 | | |
330 | 331 | | |
331 | 332 | | |
| |||
0 commit comments