code completion fixes

This commit is contained in:
Jan Prochazka 2020-06-04 13:25:45 +02:00
parent afbec02f3a
commit 86cd0c9459
2 changed files with 8 additions and 7 deletions

View File

@ -9,7 +9,7 @@ export default function analyseQuerySources(sql, sourceNames) {
const wordUpper = word.toUpperCase();
if (upperSourceNames.includes(wordUpper)) {
const preWord = tokens[i - 1];
if (preWord && /^(join)|(from)|(update)|(delete)|(insert)$/i.test(preWord)) {
if (preWord && /^((join)|(from)|(update)|(delete)|(insert))$/i.test(preWord)) {
let postWord = tokens[i + 1];
if (postWord && /^as$/i.test(postWord)) {
postWord = tokens[i + 2];
@ -18,7 +18,10 @@ export default function analyseQuerySources(sql, sourceNames) {
res.push({
name: word,
});
} else if (/^(where)|(inner)|(left)|(right)|(on)|(join)$/i.test(postWord)) {
} else if (
/^((where)|(inner)|(left)|(right)|(on)|(join))$/i.test(postWord) ||
!/^[a-zA-Z][a-zA-Z0-9]*$/i.test(postWord)
) {
res.push({
name: word,
});

View File

@ -111,11 +111,9 @@ export default function useCodeCompletion({ conid, database, tabVisible, current
editor.execCommand('startAutocomplete');
}
// if (e.args == ' ' || e.args == '.') {
// if (/from\s*$/i.test(line)) {
// currentEditorRef.current.editor.execCommand('startAutocomplete');
// }
// }
if (e.args == ' ' && /((from)|(join))\s*$/i.test(line)) {
editor.execCommand('startAutocomplete');
}
}
};