fix(editor): preserve SQL selection when executing from toolbar

This commit is contained in:
二丫讲梵 authored and GitHub committed 2026-08-30 03:05:43 +08:00
1 parent 22775f3639
commit d5f4eadf7a
6 files changed
+69 -6

No files matched your search

@@ -870,6 +870,18 @@ function emitExecutionRequest(source: SqlExecutionOverride, openInNewResultTab =
}
}
/**
* Captures a manual selection before a toolbar click can cause a platform
* focus transition. The snapshot is immutable, so downstream execution keeps
* the exact SQL and source offsets that were visible when the button was
* pressed.
*/
function captureExecutionSnapshot(): SqlExecutionSnapshot | undefined {
const currentView = view.value;
if (!currentView || currentView.state.selection.main.empty) return undefined;
return sqlExecutionSnapshotFromView(currentView);
}
function requestExecute(options: RequestExecuteOptions = {}) {
executionViewportOwnership.cancelPendingRequest();
const currentView = view.value;
@@ -6525,6 +6537,7 @@ defineExpose({
shouldBlockExecutionShortcut,
requestExecute,
requestExecuteInNewResultTab,
captureExecutionSnapshot,
pasteClipboardAsSqlInCondition,
focusStatementRange,
previewStatementRange,