2 files changed
+50
-5
No files matched your search
@@ -2211,10 +2211,10 @@ function activeSqlCompletionStatementSpan(sql: string, cursor: number, options:
|
||||
|
||||
function currentSqlLikeLineBlockSpan(sql: string, cursor: number, activeStatementSpan: SqlSemanticSpan): SqlSemanticSpan | null {
|
||||
const safeCursor = Math.max(0, Math.min(cursor, sql.length));
|
||||
const beforeCursor = sql.slice(0, safeCursor);
|
||||
const beforeCursor = sql.slice(activeStatementSpan.start, safeCursor);
|
||||
const lines = beforeCursor.split(/\r?\n/);
|
||||
let start: number | null = null;
|
||||
let offset = 0;
|
||||
let offset = activeStatementSpan.start;
|
||||
|
||||
for (const line of lines) {
|
||||
const trimmed = line.trimStart();
|
||||
@@ -2223,14 +2223,16 @@ function currentSqlLikeLineBlockSpan(sql: string, cursor: number, activeStatemen
|
||||
if (/^(select|with)\b/i.test(trimmed)) start = offset + indentation;
|
||||
if (/^(get|post|put|delete|patch|head)\s+\//i.test(trimmed)) start = null;
|
||||
}
|
||||
offset += line.length + 1;
|
||||
offset += line.length;
|
||||
offset += sql[offset] === "\r" && sql[offset + 1] === "\n" ? 2 : 1;
|
||||
}
|
||||
|
||||
if (start == null) return null;
|
||||
if (activeStatementSpan.start > start) return null;
|
||||
|
||||
const blockEnd = currentLineBlockEnd(sql, safeCursor, start);
|
||||
return { start, end: blockEnd == null ? activeStatementSpan.end : Math.min(activeStatementSpan.end, blockEnd) };
|
||||
const statementSql = sql.slice(activeStatementSpan.start, activeStatementSpan.end);
|
||||
const blockEnd = currentLineBlockEnd(statementSql, safeCursor - activeStatementSpan.start, start - activeStatementSpan.start);
|
||||
return { start, end: blockEnd == null ? activeStatementSpan.end : Math.min(activeStatementSpan.end, activeStatementSpan.start + blockEnd) };
|
||||
}
|
||||
|
||||
// Equal-length masking of string/comment characters, so parenthesis depth and
|
||||
|
||||
Reference in new issue
Block a user