File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed
extensions/ql-vscode/src/queries-panel Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -60,6 +60,23 @@ export class QueriesPanel extends DisposableObject {
6060
6161 void this . revealTextEditor ( changedTextEditor ) ;
6262 } ) ;
63+
64+ // If there is an active text editor when activating the extension, we want to show it in the tree view.
65+ if ( window . activeTextEditor ) {
66+ // We need to wait for the data provider to load its data. Without this, we will end up in a situation
67+ // where we're trying to show an item that does not exist yet since the query discoverer has not yet
68+ // finished running.
69+ const initialEventDisposable = this . dataProvider . onDidChangeTreeData (
70+ ( ) => {
71+ if ( window . activeTextEditor && this . treeView . visible ) {
72+ void this . revealTextEditor ( window . activeTextEditor ) ;
73+ }
74+
75+ // We only want to listen to this event once, so dispose of the listener to unsubscribe.
76+ initialEventDisposable . dispose ( ) ;
77+ } ,
78+ ) ;
79+ }
6380 }
6481
6582 private revealTextEditor ( textEditor : TextEditor ) : void {
You can’t perform that action at this time.
0 commit comments