From 848869e3f476eaa0bf1b23d8fb3d03c1341e655c Mon Sep 17 00:00:00 2001 From: Musab Guma'a Date: Wed, 27 Oct 2021 20:09:10 +0100 Subject: [PATCH] Make "Open Referenced File" command functional on open .qlref --- extensions/ql-vscode/CHANGELOG.md | 1 + extensions/ql-vscode/src/extension.ts | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/extensions/ql-vscode/CHANGELOG.md b/extensions/ql-vscode/CHANGELOG.md index d230ad83f..4b8282b6a 100644 --- a/extensions/ql-vscode/CHANGELOG.md +++ b/extensions/ql-vscode/CHANGELOG.md @@ -7,6 +7,7 @@ - Fix a bug with importing large databases. Databases over 4GB can now be imported directly from LGTM or from a zip file. This functionality is only available when using CodeQL CLI version 2.6.0 or later. [#971](https://github.com/github/vscode-codeql/pull/971) - Replace certain control codes (`U+0000` - `U+001F`) with their corresponding control labels (`U+2400` - `U+241F`) in the results view. [#963](https://github.com/github/vscode-codeql/pull/963) - Allow case-insensitive project slugs for GitHub repositories when adding a CodeQL database from LGTM. [#978](https://github.com/github/vscode-codeql/pull/961) +- Make "Open Referenced File" command accessible from the active editor menu. [#989](https://github.com/github/vscode-codeql/pull/989) ## 1.5.6 - 07 October 2021 diff --git a/extensions/ql-vscode/src/extension.ts b/extensions/ql-vscode/src/extension.ts index 08374c533..51eea3cae 100644 --- a/extensions/ql-vscode/src/extension.ts +++ b/extensions/ql-vscode/src/extension.ts @@ -496,9 +496,11 @@ async function activateWithInstalledDistribution( async function openReferencedFile( selectedQuery: Uri ): Promise { - if (qs !== undefined) { + // If no file is selected, the path of the file in the editor is selected + const path = selectedQuery?.fsPath || window.activeTextEditor?.document.uri.fsPath; + if (qs !== undefined && path) { if (await cliServer.cliConstraints.supportsResolveQlref()) { - const resolved = await cliServer.resolveQlref(selectedQuery.fsPath); + const resolved = await cliServer.resolveQlref(path); const uri = Uri.file(resolved.resolvedPath); await window.showTextDocument(uri, { preview: false }); } else {