Fix:修复左侧运行多条 SQL 只执行首条 (#2256)

Co-authored-by: staff <staff@qimaos-MacBook-Pro.local>
This commit is contained in:
zipg 2026-07-01 00:00:26 +08:00 committed by GitHub
parent ea2b5d1bfd
commit 910fde75e1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 9 additions and 4 deletions

View File

@ -335,15 +335,20 @@ function handleTab(view: EditorViewType): boolean {
return true;
}
function requestExecute(options: { forceCurrent?: boolean } = {}) {
interface RequestExecuteOptions {
forceCurrent?: boolean;
ignoreSelection?: boolean;
}
function requestExecute(options: RequestExecuteOptions = {}) {
const currentView = view.value;
if (!currentView) return false;
return requestExecuteFromView(currentView, currentView.state.selection.main.head, options);
}
function requestExecuteFromView(currentView: EditorViewType, cursorPos: number, options: { forceCurrent?: boolean } = {}) {
function requestExecuteFromView(currentView: EditorViewType, cursorPos: number, options: RequestExecuteOptions = {}) {
const selection = currentView.state.selection.main;
if (!selection.empty) {
if (!options.ignoreSelection && !selection.empty) {
// Has manual selection execute directly, skip picker.
emit("execute", sqlExecutionSnapshotFromView(currentView));
return true;
@ -524,7 +529,7 @@ function executeSqlStatementFromGutter(currentView: EditorViewType, line: { from
if (!statementRange) return false;
event.preventDefault();
event.stopPropagation();
emit("execute", statementRange.sql);
requestExecuteFromView(currentView, line.from, { ignoreSelection: true });
currentView.focus();
return true;
}