From e69b9768eedeb29d510f8c97487d6c83fd55af90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Dzieko=C5=84ski?= Date: Sat, 14 Sep 2024 03:20:09 +0200 Subject: [PATCH 1/2] fix(TheEditor): Trigger gotoLine only when change originates from sidebar MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Michał Dziekoński --- src/components/TheEditor.vue | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/components/TheEditor.vue b/src/components/TheEditor.vue index 215ed1ccd..a49450fca 100644 --- a/src/components/TheEditor.vue +++ b/src/components/TheEditor.vue @@ -74,7 +74,8 @@ @@ -190,6 +191,7 @@ export default class TheEditor extends Mixins(BaseMixin) { fileStructureSidebar = true structureActive: number[] = [] structureOpen: number[] = [] + structureActiveChangedBySidebar: boolean = false formatFilesize = formatFilesize @@ -424,7 +426,17 @@ export default class TheEditor extends Mixins(BaseMixin) { this.fileStructureSidebar = !this.fileStructureSidebar } + // Relies on event bubbling to flip the flag before treeview active change is handled + activeChangesItemClick() { + this.structureActiveChangedBySidebar = true + } + activeChanges(key: any) { + if (!this.structureActiveChangedBySidebar) { + return + } + + this.structureActiveChangedBySidebar = false this.editor?.gotoLine(key) } From 52de8fca3ae9660441f27e9ce78f8ad2d06082c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Dzieko=C5=84ski?= Date: Sat, 14 Sep 2024 03:40:21 +0200 Subject: [PATCH 2/2] fix(TheEditor): No sidebar item deactivation - don't blow up MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Michał Dziekoński --- src/components/TheEditor.vue | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/components/TheEditor.vue b/src/components/TheEditor.vue index a49450fca..dce57ec45 100644 --- a/src/components/TheEditor.vue +++ b/src/components/TheEditor.vue @@ -67,7 +67,7 @@ dense :active="structureActive" :open="structureOpen" - item-key="line" + :item-key="treeviewItemKeyProp" :items="configFileStructure" class="w-100" @update:active="activeChanges"> @@ -189,6 +189,7 @@ export default class TheEditor extends Mixins(BaseMixin) { dialogConfirmChange = false dialogDevices = false fileStructureSidebar = true + treeviewItemKeyProp = 'line' as const structureActive: number[] = [] structureOpen: number[] = [] structureActiveChangedBySidebar: boolean = false @@ -431,13 +432,18 @@ export default class TheEditor extends Mixins(BaseMixin) { this.structureActiveChangedBySidebar = true } - activeChanges(key: any) { + activeChanges(activeItems: Array) { if (!this.structureActiveChangedBySidebar) { return } this.structureActiveChangedBySidebar = false - this.editor?.gotoLine(key) + + if (!activeItems.length) { + return + } + + this.editor?.gotoLine(activeItems[0]) } lineChanges(line: number) {