diff --git a/extensions/ql-vscode/src/astViewer.ts b/extensions/ql-vscode/src/astViewer.ts index acd7e9915e4..662d4b603a5 100644 --- a/extensions/ql-vscode/src/astViewer.ts +++ b/extensions/ql-vscode/src/astViewer.ts @@ -8,6 +8,7 @@ import { TreeItem, TreeView, TextEditorSelectionChangeEvent, + TextEditorSelectionChangeKind, Location, Range } from 'vscode'; @@ -33,7 +34,7 @@ export interface ChildAstItem extends AstItem { parent: ChildAstItem | AstItem; } -class AstViewerDataProvider extends DisposableObject implements TreeDataProvider { +class AstViewerDataProvider extends DisposableObject implements TreeDataProvider { public roots: AstItem[] = []; public db: DatabaseItem | undefined; @@ -47,9 +48,9 @@ class AstViewerDataProvider extends DisposableObject implements TreeDataProvide super(); this.push( commandRunner('codeQLAstViewer.gotoCode', - async (item: AstItem) => { - await showLocation(item.fileLocation); - }) + async (item: AstItem) => { + await showLocation(item.fileLocation); + }) ); } @@ -160,6 +161,11 @@ export class AstViewer extends DisposableObject { return; } + // Avoid recursive tree-source code updates. + if (e.kind === TextEditorSelectionChangeKind.Command) { + return; + } + if ( this.treeView.visible && e.textEditor.document.uri.fsPath === this.currentFile &&