Skip to content

Commit d4bb052

Browse files
committed
feat(diagram): fix selection update on tab switch - #355
1 parent e0dde9b commit d4bb052

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/diagram.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,13 @@ export type DiagramSelectionMode = 'highlight' | 'hide';
6363
* This also routes updates to the correct panel when the text selection updates in a panel
6464
*/
6565
class DiagramUpdateCoordinator {
66-
private editorToDiagramPanel: Map<vscode.TextDocument, Set<DiagramPanelInformation>>;
66+
private documentToDiagramPanel: Map<vscode.TextDocument, Set<DiagramPanelInformation>>;
6767
private output: vscode.OutputChannel;
6868
private debounceTimeout: NodeJS.Timeout | undefined;
6969
private debounceTime = 250; //ms
7070

7171
constructor(output: vscode.OutputChannel) {
72-
this.editorToDiagramPanel = new Map<vscode.TextDocument, Set<DiagramPanelInformation>>();
72+
this.documentToDiagramPanel = new Map<vscode.TextDocument, Set<DiagramPanelInformation>>();
7373
this.output = output;
7474
}
7575

@@ -91,7 +91,7 @@ class DiagramUpdateCoordinator {
9191

9292
// Stop tracking panel when user closes it
9393
panel.onDidDispose(() => {
94-
this.editorToDiagramPanel.get(editor.document)?.delete(info);
94+
this.documentToDiagramPanel.get(editor.document)?.delete(info);
9595
});
9696

9797
// Handle settings update messages from panel
@@ -115,11 +115,11 @@ class DiagramUpdateCoordinator {
115115
});
116116

117117
// Add panel to map for tracking selection updates
118-
if(!this.editorToDiagramPanel.has(editor.document)) {
119-
this.editorToDiagramPanel.set(editor.document, new Set<DiagramPanelInformation>());
118+
if(!this.documentToDiagramPanel.has(editor.document)) {
119+
this.documentToDiagramPanel.set(editor.document, new Set<DiagramPanelInformation>());
120120
}
121121

122-
this.editorToDiagramPanel.get(editor.document)?.add(info);
122+
this.documentToDiagramPanel.get(editor.document)?.add(info);
123123

124124
return {
125125
mermaid,
@@ -136,7 +136,7 @@ class DiagramUpdateCoordinator {
136136

137137
// Update when the last debounce timeout runs out
138138
this.debounceTimeout = setTimeout(() => {
139-
const panelsToUpdate = this.editorToDiagramPanel.get(e.textEditor.document);
139+
const panelsToUpdate = this.documentToDiagramPanel.get(e.textEditor.document);
140140
if(!panelsToUpdate) {
141141
return;
142142
}

0 commit comments

Comments
 (0)