1
1
// Copyright (c) Microsoft Corporation. All rights reserved.
2
2
// Licensed under the MIT license.
3
3
4
- import { ExtensionContext , ProviderResult , TextEditor , TreeView , Uri , window } from "vscode" ;
4
+ import { ExtensionContext , ProviderResult , TextEditor , TreeView , TreeViewVisibilityChangeEvent , Uri , window } from "vscode" ;
5
5
import { Jdtls } from "../java/jdtls" ;
6
6
import { INodeData } from "../java/nodeData" ;
7
7
import { Settings } from "../settings" ;
@@ -16,6 +16,8 @@ export class DependencyExplorer {
16
16
17
17
private _dataProvider : DependencyDataProvider ;
18
18
19
+ private _selectionWhenHidden : DataNode ;
20
+
19
21
constructor ( public readonly context : ExtensionContext ) {
20
22
this . _dataProvider = new DependencyDataProvider ( context ) ;
21
23
this . _dependencyViewer = window . createTreeView ( "javaDependencyExplorer" , { treeDataProvider : this . _dataProvider } ) ;
@@ -25,6 +27,13 @@ export class DependencyExplorer {
25
27
this . reveal ( textEditor . document . uri ) ;
26
28
}
27
29
} ) ;
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
+ } ) ;
28
37
}
29
38
30
39
public dispose ( ) : void {
@@ -56,7 +65,11 @@ export class DependencyExplorer {
56
65
for ( const c of children ) {
57
66
if ( c . path === paths [ 0 ] . path ) {
58
67
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
+ }
60
73
} else {
61
74
paths . shift ( ) ;
62
75
this . revealPath ( c , paths ) ;
0 commit comments