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 cb30009
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions extensions/ql-vscode/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
- Allow setting `codeQL.runningQueries.numberOfThreads` and `codeQL.runningTests.numberOfThreads` to 0, (which is interpreted as 'use one thread per core on the machine').
- Clear the problems view of all CodeQL query results when a database is removed.
- Add a `View DIL` command on query history items. This opens a text editor containing the Datalog Intermediary Language representation of the compiled query.
- 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.

## 1.3.3 - 16 September 2020

Expand Down
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 cb30009

Please sign in to comment.