Skip to content

Commit 1f5334d

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 1f5334d

3 files changed

Lines changed: 14 additions & 1 deletion

File tree

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)