Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid recursive selection changes in ast viewer #668

Merged
merged 1 commit into from
Nov 4, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions extensions/ql-vscode/src/astViewer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
TreeItem,
TreeView,
TextEditorSelectionChangeEvent,
TextEditorSelectionChangeKind,
Location,
Range
} from 'vscode';
Expand All @@ -33,7 +34,7 @@ export interface ChildAstItem extends AstItem {
parent: ChildAstItem | AstItem;
}

class AstViewerDataProvider extends DisposableObject implements TreeDataProvider<AstItem> {
class AstViewerDataProvider extends DisposableObject implements TreeDataProvider<AstItem> {

public roots: AstItem[] = [];
public db: DatabaseItem | undefined;
Expand All @@ -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);
})
);
}

Expand Down Expand Up @@ -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 &&
Expand Down