fix(Editor): Trigger gotoLine only when change is from sidebar (#2012)
This commit is contained in:
committed by
GitHub
parent
f108545223
commit
682a3dce6b
@@ -67,14 +67,15 @@
|
|||||||
dense
|
dense
|
||||||
:active="structureActive"
|
:active="structureActive"
|
||||||
:open="structureOpen"
|
:open="structureOpen"
|
||||||
item-key="line"
|
:item-key="treeviewItemKeyProp"
|
||||||
:items="configFileStructure"
|
:items="configFileStructure"
|
||||||
class="w-100"
|
class="w-100"
|
||||||
@update:active="activeChanges">
|
@update:active="activeChanges">
|
||||||
<template #label="{ item }">
|
<template #label="{ item }">
|
||||||
<div
|
<div
|
||||||
class="cursor-pointer _structure-sidebar-item"
|
class="cursor-pointer _structure-sidebar-item"
|
||||||
:class="item.type == 'item' ? 'ͼp' : 'ͼt'">
|
:class="item.type == 'item' ? 'ͼp' : 'ͼt'"
|
||||||
|
@click="activeChangesItemClick">
|
||||||
{{ item.name }}
|
{{ item.name }}
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -188,8 +189,10 @@ export default class TheEditor extends Mixins(BaseMixin) {
|
|||||||
dialogConfirmChange = false
|
dialogConfirmChange = false
|
||||||
dialogDevices = false
|
dialogDevices = false
|
||||||
fileStructureSidebar = true
|
fileStructureSidebar = true
|
||||||
|
treeviewItemKeyProp = 'line' as const
|
||||||
structureActive: number[] = []
|
structureActive: number[] = []
|
||||||
structureOpen: number[] = []
|
structureOpen: number[] = []
|
||||||
|
structureActiveChangedBySidebar: boolean = false
|
||||||
|
|
||||||
formatFilesize = formatFilesize
|
formatFilesize = formatFilesize
|
||||||
|
|
||||||
@@ -424,8 +427,23 @@ export default class TheEditor extends Mixins(BaseMixin) {
|
|||||||
this.fileStructureSidebar = !this.fileStructureSidebar
|
this.fileStructureSidebar = !this.fileStructureSidebar
|
||||||
}
|
}
|
||||||
|
|
||||||
activeChanges(key: any) {
|
// Relies on event bubbling to flip the flag before treeview active change is handled
|
||||||
this.editor?.gotoLine(key)
|
activeChangesItemClick() {
|
||||||
|
this.structureActiveChangedBySidebar = true
|
||||||
|
}
|
||||||
|
|
||||||
|
activeChanges(activeItems: Array<ConfigFileSection[typeof this.treeviewItemKeyProp]>) {
|
||||||
|
if (!this.structureActiveChangedBySidebar) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
this.structureActiveChangedBySidebar = false
|
||||||
|
|
||||||
|
if (!activeItems.length) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
this.editor?.gotoLine(activeItems[0])
|
||||||
}
|
}
|
||||||
|
|
||||||
lineChanges(line: number) {
|
lineChanges(line: number) {
|
||||||
|
Reference in New Issue
Block a user