Skip to content

Commit 16554ab

Browse files
authored
Merge pull request #212 from RasmusWL/reuse-existing-texteditor
Reuse existing editor if file already open
2 parents 20a4e0a + 3454be2 commit 16554ab

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

extensions/ql-vscode/src/interface.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,10 @@ async function showLocation(loc: ResolvableLocationValue, databaseItem: Database
427427
const resolvedLocation = tryResolveLocation(loc, databaseItem);
428428
if (resolvedLocation) {
429429
const doc = await workspace.openTextDocument(resolvedLocation.uri);
430-
const editor = await Window.showTextDocument(doc, vscode.ViewColumn.One);
430+
const editorsWithDoc = Window.visibleTextEditors.filter(e => e.document === doc);
431+
const editor = editorsWithDoc.length > 0
432+
? editorsWithDoc[0]
433+
: await Window.showTextDocument(doc, vscode.ViewColumn.One);
431434
let range = resolvedLocation.range;
432435
// When highlighting the range, vscode's occurrence-match and bracket-match highlighting will
433436
// trigger based on where we place the cursor/selection, and will compete for the user's attention.

0 commit comments

Comments
 (0)