Skip to content

Commit cb30009

Browse files
committed
Open editor containing query location in non-preview mode
Adds a new config option to control this behavior. If this behavior is generally desirable, we will remove the option and avoid using preview editors for all users.
1 parent 8fac685 commit cb30009

4 files changed

Lines changed: 15 additions & 1 deletion

File tree

extensions/ql-vscode/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
- Allow setting `codeQL.runningQueries.numberOfThreads` and `codeQL.runningTests.numberOfThreads` to 0, (which is interpreted as 'use one thread per core on the machine').
1414
- Clear the problems view of all CodeQL query results when a database is removed.
1515
- Add a `View DIL` command on query history items. This opens a text editor containing the Datalog Intermediary Language representation of the compiled query.
16+
- Add the `codeQL.ui.openInPreviewEditor` config option. This option allows users to open query results in non-preview editors (by un-checking this option). Doing so will make navigation between results files easier, but may also contribute to a proliferation of open editors.
1617

1718
## 1.3.3 - 16 September 2020
1819

extensions/ql-vscode/package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,11 @@
110110
"type": "object",
111111
"title": "CodeQL",
112112
"properties": {
113+
"codeQL.ui.openInPreviewEditor": {
114+
"type": "boolean",
115+
"default": true,
116+
"markdownDescription": "When enabled (default), query results will in a _preview_ editor. Disabling will make navigation between results easier, but will also result in a proliferation of open editors."
117+
},
113118
"codeQL.cli.executablePath": {
114119
"scope": "machine",
115120
"type": "string",

extensions/ql-vscode/src/config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,10 @@ const NUMBER_OF_THREADS_SETTING = new Setting('numberOfThreads', RUNNING_QUERIES
6767
const TIMEOUT_SETTING = new Setting('timeout', RUNNING_QUERIES_SETTING);
6868
const MEMORY_SETTING = new Setting('memory', RUNNING_QUERIES_SETTING);
6969
const DEBUG_SETTING = new Setting('debug', RUNNING_QUERIES_SETTING);
70+
const UI_SETTING = new Setting('ui', ROOT_SETTING);
7071
export const MAX_QUERIES = new Setting('maxQueries', RUNNING_QUERIES_SETTING);
7172
export const AUTOSAVE_SETTING = new Setting('autoSave', RUNNING_QUERIES_SETTING);
73+
export const OPEN_IN_PREVIEW = new Setting('openInPreviewEditor', UI_SETTING);
7274

7375
/** When these settings change, the running query server should be restarted. */
7476
const QUERY_SERVER_RESTARTING_SETTINGS = [NUMBER_OF_THREADS_SETTING, MEMORY_SETTING, DEBUG_SETTING];

extensions/ql-vscode/src/interface-utils.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { DatabaseItem, DatabaseManager } from './databases';
2020
import { ViewSourceFileMsg } from './interface-types';
2121
import { Logger } from './logging';
2222
import { LineColumnLocation, WholeFileLocation, UrlValue, ResolvableLocationValue } from './bqrs-cli-types';
23+
import { OPEN_IN_PREVIEW } from './config';
2324

2425
/**
2526
* This module contains functions and types that are sharedd between
@@ -162,7 +163,12 @@ export async function showLocation(location?: Location) {
162163
const editor =
163164
editorsWithDoc.length > 0
164165
? editorsWithDoc[0]
165-
: await Window.showTextDocument(doc, ViewColumn.One);
166+
: await Window.showTextDocument(
167+
doc, {
168+
preview: OPEN_IN_PREVIEW.getValue<boolean>(),
169+
viewColumn: ViewColumn.One,
170+
});
171+
166172
const range = location.range;
167173
// When highlighting the range, vscode's occurrence-match and bracket-match highlighting will
168174
// trigger based on where we place the cursor/selection, and will compete for the user's attention.

0 commit comments

Comments
 (0)