fix: guard mock suggestions for vectorsdb, optimize fold scan

- Add !isVectorsDb guard to useMockSuggestions derivation
- Use single sliceString for bracket matching instead of per-char rope traversal
This commit is contained in:
Prem Palanisamy
2026-03-18 10:41:15 +00:00
parent 61c1e82578
commit 218be1405b
2 changed files with 6 additions and 5 deletions
@@ -1039,15 +1039,15 @@
if (!match) continue;
const bracketPos = line.from + match[1].length;
const tail = doc.sliceString(bracketPos, doc.length);
let depth = 0;
let closePos = -1;
for (let i = bracketPos; i < doc.length; i++) {
const ch = doc.sliceString(i, i + 1);
if (ch === '[') depth++;
else if (ch === ']') {
for (let i = 0; i < tail.length; i++) {
if (tail[i] === '[') depth++;
else if (tail[i] === ']') {
depth--;
if (depth === 0) {
closePos = i;
closePos = bracketPos + i;
break;
}
}
@@ -571,6 +571,7 @@
const MIN_DOCS_FOR_FUZZY_SUGGESTIONS = 5;
$: useMockSuggestions =
!isVectorsDb &&
$noSqlDocument.isNew &&
($documents?.documents?.length ?? 0) < MIN_DOCS_FOR_FUZZY_SUGGESTIONS;