fix(editor): preserve snippet navigation after dismissing completion
This commit is contained in:
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);
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user