fix(editor): preserve current SQL execution boundaries

This commit is contained in:
zipg authored and GitHub committed 2026-08-04 00:37:42 +08:00
1 parent c9764be9a0
commit a6f1a9a871
13 files changed
+232 -44

No files matched your search

@@ -23,6 +23,7 @@ export type SqlExecutionTargetKind = "cursor" | "all";
*/
export interface SqlExecutionCandidate {
kind: SqlExecutionTargetKind;
supportedKinds: SqlExecutionTargetKind[];
label: string;
sql: string;
from: number;
@@ -40,6 +41,11 @@ export function isSqlExecutionSnapshot(value: SqlExecutionOverride | undefined):
return typeof value === "object" && value !== null && typeof value.fullSql === "string" && typeof value.selectedSql === "string" && typeof value.cursorPos === "number" && typeof value.selectionFrom === "number" && typeof value.selectionTo === "number";
}
export function executionCandidateForMode(candidates: SqlExecutionCandidate[], mode: ExecuteMode): SqlExecutionCandidate | null {
const targetKind: SqlExecutionTargetKind = mode === "current" ? "cursor" : "all";
return candidates.find((candidate) => candidate.supportedKinds.includes(targetKind)) ?? null;
}
export function resolveExecutableSql(fullSql: string, selectedSql: string, options?: { mode?: ExecuteMode; cursorPos?: number }): string {
const trimmedSelection = selectedSql.trim();
if (trimmedSelection) return trimmedSelection;