Skip to content

Commit ede9b7a

Browse files
authored
Fix issue 83: Dependency view sync with opened files should only work when the side bar is visible.
1 parent a521ea6 commit ede9b7a

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/views/dependencyExplorer.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT license.
33

4-
import { ExtensionContext, ProviderResult, TextEditor, TreeView, Uri, window } from "vscode";
4+
import { ExtensionContext, ProviderResult, TextEditor, TreeView, TreeViewVisibilityChangeEvent, Uri, window } from "vscode";
55
import { Jdtls } from "../java/jdtls";
66
import { INodeData } from "../java/nodeData";
77
import { Settings } from "../settings";
@@ -16,6 +16,8 @@ export class DependencyExplorer {
1616

1717
private _dataProvider: DependencyDataProvider;
1818

19+
private _selectionWhenHidden: DataNode;
20+
1921
constructor(public readonly context: ExtensionContext) {
2022
this._dataProvider = new DependencyDataProvider(context);
2123
this._dependencyViewer = window.createTreeView("javaDependencyExplorer", { treeDataProvider: this._dataProvider });
@@ -25,6 +27,13 @@ export class DependencyExplorer {
2527
this.reveal(textEditor.document.uri);
2628
}
2729
});
30+
31+
this._dependencyViewer.onDidChangeVisibility((e: TreeViewVisibilityChangeEvent) => {
32+
if (e.visible && this._selectionWhenHidden) {
33+
this._dependencyViewer.reveal(this._selectionWhenHidden);
34+
this._selectionWhenHidden = undefined;
35+
}
36+
});
2837
}
2938

3039
public dispose(): void {
@@ -56,7 +65,11 @@ export class DependencyExplorer {
5665
for (const c of children) {
5766
if (c.path === paths[0].path) {
5867
if (paths.length === 1) {
59-
this._dependencyViewer.reveal(c);
68+
if (this._dependencyViewer.visible) {
69+
this._dependencyViewer.reveal(c);
70+
} else {
71+
this._selectionWhenHidden = c;
72+
}
6073
} else {
6174
paths.shift();
6275
this.revealPath(c, paths);

0 commit comments

Comments
 (0)