Skip to content

Commit 87bbf29

Browse files
authored
Merge pull request #2660 from github/aeisenberg/qhelp-preview
Ensure the qhelp preview is refreshed after editing
2 parents 36f92da + d7d1351 commit 87bbf29

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

extensions/ql-vscode/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
- Remove "last updated" information and sorting from variant analysis results view. [#2637](https://github.com/github/vscode-codeql/pull/2637)
88
- Links to code on GitHub now include column numbers as well as line numbers. [#2406](https://github.com/github/vscode-codeql/pull/2406)
99
- No longer highlight trailing commas for jump to definition. [#2615](https://github.com/github/vscode-codeql/pull/2615)
10+
- Fix a bug where the QHelp preview page was not being refreshed after changes to the underlying `.qhelp` file. [#2660](https://github.com/github/vscode-codeql/pull/2660)
1011

1112
## 1.8.8 - 17 July 2023
1213

extensions/ql-vscode/src/common/commands.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ type BuiltInVsCodeCommands = {
5959
// The codeQLDatabases.focus command is provided by VS Code because we've registered the custom view
6060
"codeQLDatabases.focus": () => Promise<void>;
6161
"markdown.showPreviewToSide": (uri: Uri) => Promise<void>;
62+
"workbench.action.closeActiveEditor": () => Promise<void>;
6263
revealFileInOS: (uri: Uri) => Promise<void>;
6364
setContext: (
6465
key: `${"codeql" | "codeQL"}${string}`,

extensions/ql-vscode/src/language-support/query-editor.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Uri, window } from "vscode";
1+
import { Uri, ViewColumn, window } from "vscode";
22
import { CodeQLCliServer } from "../codeql-cli/cli";
33
import { QueryRunner } from "../query-server";
44
import { basename, join } from "path";
@@ -74,6 +74,16 @@ async function previewQueryHelp(
7474
const uri = Uri.file(absolutePathToMd);
7575
try {
7676
await cliServer.generateQueryHelp(pathToQhelp, absolutePathToMd);
77+
// Open and then close the raw markdown file first. This ensures that the preview
78+
// is refreshed when we open it in the next step.
79+
// This will mean that the users will see a the raw markdown file for a brief moment,
80+
// but this is the best we can do for now to ensure that the preview is refreshed.
81+
await window.showTextDocument(uri, {
82+
viewColumn: ViewColumn.Active,
83+
});
84+
await commandManager.execute("workbench.action.closeActiveEditor");
85+
86+
// Now open the preview
7787
await commandManager.execute("markdown.showPreviewToSide", uri);
7888
} catch (e) {
7989
const errorMessage = getErrorMessage(e).includes(

0 commit comments

Comments
 (0)