mirror of
https://github.com/t8y2/dbx.git
synced 2026-11-01 08:26:35 +00:00
feat: add execute mode settings and cursor position handling in SQL editor
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user