From e9dedfaf3203f5621e54fd707003a47e6e5a5c4d Mon Sep 17 00:00:00 2001 From: Fabio Di Stasio Date: Thu, 28 Apr 2022 13:22:15 +0200 Subject: [PATCH] fix: query editor table fields suggestion --- src/renderer/components/QueryEditor.vue | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/renderer/components/QueryEditor.vue b/src/renderer/components/QueryEditor.vue index 7eb2f9b6..daeeabbd 100644 --- a/src/renderer/components/QueryEditor.vue +++ b/src/renderer/components/QueryEditor.vue @@ -30,18 +30,21 @@ export default { }, emits: ['update:modelValue'], setup () { + const editor = null; const applicationStore = useApplicationStore(); const { setBaseCompleters } = applicationStore; const { baseCompleter } = storeToRefs(applicationStore); return { + editor, + baseCompleter, setBaseCompleters }; }, data () { return { - editor: null, + cursorPosition: 0, fields: [], customCompleter: [], id: null, @@ -139,9 +142,6 @@ export default { return 'sql'; } }, - cursorPosition () { - return this.editor.session.doc.positionToIndex(this.editor.getCursorPosition()); - }, lastWord () { const charsBefore = this.modelValue.slice(0, this.cursorPosition); const words = charsBefore.replaceAll('\n', ' ').split(' ').filter(Boolean); @@ -167,6 +167,9 @@ export default { } }, watch: { + modelValue () { + this.cursorPosition = this.editor.session.doc.positionToIndex(this.editor.getCursorPosition()); + }, editorTheme () { if (this.editor) this.editor.setTheme(`ace/theme/${this.editorTheme}`);