fix(editor): preserve snippet navigation after dismissing completion

This commit is contained in:
二丫讲梵 authored and GitHub committed 2026-09-11 23:25:18 +08:00
1 parent 2d9521898f
commit 8b1379ff4f
6 files changed
+468 -10

No files matched your search

@@ -0,0 +1,19 @@
import type { Command } from "@codemirror/view";
interface QueryEditorEscapeOptions {
clearBatchSelection: () => void;
cancelPendingAcceptance: () => void;
closeSearch: () => boolean;
closeCompletion: Command;
}
/** Run at highest precedence, before the dynamically installed snippet keymap. */
export function createQueryEditorEscapeHandler(options: QueryEditorEscapeOptions): Command {
return (view) => {
options.clearBatchSelection();
options.cancelPendingAcceptance();
// Keep search dismissal first. Consume completion dismissal so Escape does
// not reach clearSnippet and discard the remaining placeholder navigation.
return options.closeSearch() || options.closeCompletion(view);
};
}