From c5baf2b0d379fdd28ee8cb907628bbfca940e2f6 Mon Sep 17 00:00:00 2001 From: Fabio Di Stasio Date: Sun, 15 May 2022 18:15:05 +0200 Subject: [PATCH] fix: query tab content disappears reordering or closing other tabs, closes #261 --- src/renderer/components/WorkspaceTabQuery.vue | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/renderer/components/WorkspaceTabQuery.vue b/src/renderer/components/WorkspaceTabQuery.vue index ecd2dcb7..5a402ffa 100644 --- a/src/renderer/components/WorkspaceTabQuery.vue +++ b/src/renderer/components/WorkspaceTabQuery.vue @@ -255,7 +255,8 @@ export default { durationsCount: 0, affectedCount: null, editorHeight: 200, - isHistoryOpen: false + isHistoryOpen: false, + debounceTimeout: null }; }, computed: { @@ -285,6 +286,19 @@ export default { } }, watch: { + query (val) { + clearTimeout(this.debounceTimeout); + + this.debounceTimeout = setTimeout(() => { + this.updateTabContent({ + uid: this.connection.uid, + tab: this.tab.uid, + type: 'query', + schema: this.selectedSchema, + content: val + }); + }, 200); + }, isSelected (val) { if (val) { this.changeBreadcrumbs({ schema: this.selectedSchema, query: `Query #${this.tab.index}` }); @@ -357,13 +371,6 @@ export default { return acc + (curr.report ? curr.report.affectedRows : 0); }, null); - this.updateTabContent({ - uid: this.connection.uid, - tab: this.tab.uid, - type: 'query', - schema: this.selectedSchema, - content: query - }); this.saveHistory(params); if (!this.autocommit) this.setUnsavedChanges({ uid: this.connection.uid, tUid: this.tabUid, isChanged: true });