Skip to content

Commit

Permalink
Open editor containing query location in non-preview mode
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
aeisenberg committed Oct 20, 2020
1 parent 8fac685 commit 1f5334d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
5 changes: 5 additions & 0 deletions extensions/ql-vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,11 @@
"type": "object",
"title": "CodeQL",
"properties": {
"codeQL.ui.openInPreviewEditor": {
"type": "boolean",
"default": true,
"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."
},
"codeQL.cli.executablePath": {
"scope": "machine",
"type": "string",
Expand Down
2 changes: 2 additions & 0 deletions extensions/ql-vscode/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,10 @@ const NUMBER_OF_THREADS_SETTING = new Setting('numberOfThreads', RUNNING_QUERIES
const TIMEOUT_SETTING = new Setting('timeout', RUNNING_QUERIES_SETTING);
const MEMORY_SETTING = new Setting('memory', RUNNING_QUERIES_SETTING);
const DEBUG_SETTING = new Setting('debug', RUNNING_QUERIES_SETTING);
const UI_SETTING = new Setting('ui', ROOT_SETTING);
export const MAX_QUERIES = new Setting('maxQueries', RUNNING_QUERIES_SETTING);
export const AUTOSAVE_SETTING = new Setting('autoSave', RUNNING_QUERIES_SETTING);
export const OPEN_IN_PREVIEW = new Setting('openInPreviewEditor', UI_SETTING);

/** When these settings change, the running query server should be restarted. */
const QUERY_SERVER_RESTARTING_SETTINGS = [NUMBER_OF_THREADS_SETTING, MEMORY_SETTING, DEBUG_SETTING];
Expand Down
8 changes: 7 additions & 1 deletion extensions/ql-vscode/src/interface-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { DatabaseItem, DatabaseManager } from './databases';
import { ViewSourceFileMsg } from './interface-types';
import { Logger } from './logging';
import { LineColumnLocation, WholeFileLocation, UrlValue, ResolvableLocationValue } from './bqrs-cli-types';
import { OPEN_IN_PREVIEW } from './config';

/**
* This module contains functions and types that are sharedd between
Expand Down Expand Up @@ -162,7 +163,12 @@ export async function showLocation(location?: Location) {
const editor =
editorsWithDoc.length > 0
? editorsWithDoc[0]
: await Window.showTextDocument(doc, ViewColumn.One);
: await Window.showTextDocument(
doc, {
preview: OPEN_IN_PREVIEW.getValue<boolean>(),
viewColumn: ViewColumn.One,
});

const range = location.range;
// When highlighting the range, vscode's occurrence-match and bracket-match highlighting will
// trigger based on where we place the cursor/selection, and will compete for the user's attention.
Expand Down

0 comments on commit 1f5334d

Please sign in to comment.