Skip to content

Commit 80c168b

Browse files
committed
hotfix: the auto suggestion for enum
1 parent cdcf8f9 commit 80c168b

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/renderer/components/CodeEditor/handleCustomSqlAutoComplete.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,20 @@ function searchForIdentifier(
2424
let currentNode = node.prevSibling;
2525
while (currentNode) {
2626
if (['CompositeIdentifier', 'Identifier'].includes(currentNode.type.name)) {
27-
return getNodeString(context, currentNode);
27+
const maybeIdentifier = getNodeString(context, currentNode);
28+
if (maybeIdentifier[maybeIdentifier.length - 1] === '.') {
29+
// Maybe the identifier is not complete
30+
const nextNode = currentNode.nextSibling;
31+
if (nextNode && nextNode.type.name === 'Builtin') {
32+
return maybeIdentifier + getNodeString(context, nextNode);
33+
}
34+
}
35+
return maybeIdentifier;
2836
} else if (!allowNodeWhenSearchForIdentify(context, node)) {
2937
return null;
3038
}
3139

32-
currentNode = node.prevSibling;
40+
currentNode = currentNode.prevSibling;
3341
}
3442

3543
return null;
@@ -46,6 +54,8 @@ function handleEnumAutoComplete(
4654
return null;
4755
}
4856

57+
console.log(currentNode);
58+
4959
// This will handle
5060
// SELECT * FROM tblA WHERE tblA.colA IN (....)
5161
if (currentNode?.parent?.type?.name === 'Parens') {
@@ -56,6 +66,8 @@ function handleEnumAutoComplete(
5666

5767
// Let search for identifer
5868
const identifier = searchForIdentifier(context, currentNode.prevSibling);
69+
console.log(identifier);
70+
5971
if (!identifier) return null;
6072

6173
const [table, column] = identifier.replaceAll('`', '').split('.');

0 commit comments

Comments
 (0)