1
1
mirror of https://github.com/Fabio286/antares.git synced 2025-03-09 16:00:17 +01:00

fix: query editor table fields suggestion

This commit is contained in:
Fabio Di Stasio 2022-04-28 13:22:15 +02:00
parent 9f0ec5e0ce
commit e9dedfaf32

View File

@ -30,18 +30,21 @@ export default {
}, },
emits: ['update:modelValue'], emits: ['update:modelValue'],
setup () { setup () {
const editor = null;
const applicationStore = useApplicationStore(); const applicationStore = useApplicationStore();
const { setBaseCompleters } = applicationStore; const { setBaseCompleters } = applicationStore;
const { baseCompleter } = storeToRefs(applicationStore); const { baseCompleter } = storeToRefs(applicationStore);
return { return {
editor,
baseCompleter, baseCompleter,
setBaseCompleters setBaseCompleters
}; };
}, },
data () { data () {
return { return {
editor: null, cursorPosition: 0,
fields: [], fields: [],
customCompleter: [], customCompleter: [],
id: null, id: null,
@ -139,9 +142,6 @@ export default {
return 'sql'; return 'sql';
} }
}, },
cursorPosition () {
return this.editor.session.doc.positionToIndex(this.editor.getCursorPosition());
},
lastWord () { lastWord () {
const charsBefore = this.modelValue.slice(0, this.cursorPosition); const charsBefore = this.modelValue.slice(0, this.cursorPosition);
const words = charsBefore.replaceAll('\n', ' ').split(' ').filter(Boolean); const words = charsBefore.replaceAll('\n', ' ').split(' ').filter(Boolean);
@ -167,6 +167,9 @@ export default {
} }
}, },
watch: { watch: {
modelValue () {
this.cursorPosition = this.editor.session.doc.positionToIndex(this.editor.getCursorPosition());
},
editorTheme () { editorTheme () {
if (this.editor) if (this.editor)
this.editor.setTheme(`ace/theme/${this.editorTheme}`); this.editor.setTheme(`ace/theme/${this.editorTheme}`);