feat: add execute mode settings and cursor position handling in SQL editor

This commit is contained in:
t8y2
2026-05-04 21:19:07 +08:00
parent 9ced92fdc8
commit 790791f946
9 changed files with 229 additions and 6 deletions
+16 -2
View File
@@ -1,4 +1,18 @@
export function resolveExecutableSql(fullSql: string, selectedSql: string): string {
import { findStatementAtCursor } from "./sqlStatementSplit";
export type ExecuteMode = "all" | "current";
export function resolveExecutableSql(
fullSql: string,
selectedSql: string,
options?: { mode?: ExecuteMode; cursorPos?: number },
): string {
const trimmedSelection = selectedSql.trim();
return trimmedSelection ? trimmedSelection : fullSql;
if (trimmedSelection) return trimmedSelection;
if (options?.mode === "current" && options.cursorPos !== undefined) {
return findStatementAtCursor(fullSql, options.cursorPos);
}
return fullSql;
}