mirror of https://github.com/Fabio286/antares.git
perf(UI): improved table fields suggestion in query editor
This commit is contained in:
parent
dcccb544f9
commit
c22187c305
|
@ -126,9 +126,13 @@ export default {
|
||||||
return 'sql';
|
return 'sql';
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
cursorPosition () {
|
||||||
|
return this.editor.session.doc.positionToIndex(this.editor.getCursorPosition());
|
||||||
|
},
|
||||||
lastWord () {
|
lastWord () {
|
||||||
const words = this.value.split(' ');
|
const charsBefore = this.value.slice(0, this.cursorPosition);
|
||||||
return words[words.length - 1];
|
const words = charsBefore.replaceAll('\n', ' ').split(' ').filter(Boolean);
|
||||||
|
return words.pop();
|
||||||
},
|
},
|
||||||
isLastWordATable () {
|
isLastWordATable () {
|
||||||
return /\w+\.\w*/gm.test(this.lastWord);
|
return /\w+\.\w*/gm.test(this.lastWord);
|
||||||
|
@ -209,7 +213,7 @@ export default {
|
||||||
if (['insertstring', 'backspace', 'del'].includes(e.command.name)) {
|
if (['insertstring', 'backspace', 'del'].includes(e.command.name)) {
|
||||||
if (this.isLastWordATable || e.args === '.') {
|
if (this.isLastWordATable || e.args === '.') {
|
||||||
if (e.args !== ' ') {
|
if (e.args !== ' ') {
|
||||||
const table = this.tables.find(t => t.name === this.lastWord.split('.').pop());
|
const table = this.tables.find(t => t.name === this.lastWord.split('.').pop().trim());
|
||||||
|
|
||||||
if (table) {
|
if (table) {
|
||||||
const params = {
|
const params = {
|
||||||
|
|
Loading…
Reference in New Issue