From 03d4aca63961ff406ed369eccbfa926fb25267e8 Mon Sep 17 00:00:00 2001 From: Andrew Eisenberg Date: Wed, 17 Nov 2021 16:24:48 -0800 Subject: [PATCH] Add leniency in how positions are handled (#1002) * Add leniency in how positions are handled Previously, positions with end column of 0 were rejected by the extension. CodeQL positions are supposed to be 1-based, but the CLI does handle 0-based and negative positions by using character offsets from the current line start. Instead of rejecting these kinds of positions, the extension should handle them as gracefully as possible. Fixes #999 * Add changelog entry --- extensions/ql-vscode/CHANGELOG.md | 5 +++-- extensions/ql-vscode/src/interface-utils.ts | 2 +- extensions/ql-vscode/src/pure/bqrs-utils.ts | 3 +-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/extensions/ql-vscode/CHANGELOG.md b/extensions/ql-vscode/CHANGELOG.md index 4b8282b6a..ad0225ff2 100644 --- a/extensions/ql-vscode/CHANGELOG.md +++ b/extensions/ql-vscode/CHANGELOG.md @@ -2,12 +2,13 @@ ## [UNRELEASED] -- Fix the _CodeQL: Open Referenced File_ command for Windows systems. [#979](https://github.com/github/vscode-codeql/pull/979) +- Fix the _CodeQL: Open Referenced File_ command for Windows systems. [#979](https://github.com/github/vscode-codeql/pull/979) - Fix a bug that shows 'Set current database' when hovering over the currently selected database in the databases view. [#976](https://github.com/github/vscode-codeql/pull/976) - Fix a bug with importing large databases. Databases over 4GB can now be imported directly from LGTM or from a zip file. This functionality is only available when using CodeQL CLI version 2.6.0 or later. [#971](https://github.com/github/vscode-codeql/pull/971) -- Replace certain control codes (`U+0000` - `U+001F`) with their corresponding control labels (`U+2400` - `U+241F`) in the results view. [#963](https://github.com/github/vscode-codeql/pull/963) +- Replace certain control codes (`U+0000` - `U+001F`) with their corresponding control labels (`U+2400` - `U+241F`) in the results view. [#963](https://github.com/github/vscode-codeql/pull/963) - Allow case-insensitive project slugs for GitHub repositories when adding a CodeQL database from LGTM. [#978](https://github.com/github/vscode-codeql/pull/961) - Make "Open Referenced File" command accessible from the active editor menu. [#989](https://github.com/github/vscode-codeql/pull/989) +- Allow query result locations with 0 as the end column value. These are treated as the first column in the line. [#1002](https://github.com/github/vscode-codeql/pull/1002) ## 1.5.6 - 07 October 2021 diff --git a/extensions/ql-vscode/src/interface-utils.ts b/extensions/ql-vscode/src/interface-utils.ts index 2e5a747da..7ac3d0016 100644 --- a/extensions/ql-vscode/src/interface-utils.ts +++ b/extensions/ql-vscode/src/interface-utils.ts @@ -70,7 +70,7 @@ function resolveFivePartLocation( Math.max(0, loc.startLine - 1), Math.max(0, loc.startColumn - 1), Math.max(0, loc.endLine - 1), - Math.max(0, loc.endColumn) + Math.max(1, loc.endColumn) ); return new Location(databaseItem.resolveSourceFile(loc.uri), range); diff --git a/extensions/ql-vscode/src/pure/bqrs-utils.ts b/extensions/ql-vscode/src/pure/bqrs-utils.ts index db724343c..b64de21b9 100644 --- a/extensions/ql-vscode/src/pure/bqrs-utils.ts +++ b/extensions/ql-vscode/src/pure/bqrs-utils.ts @@ -83,8 +83,7 @@ export function isLineColumnLoc(loc: UrlValue): loc is LineColumnLocation { && 'startLine' in loc && 'startColumn' in loc && 'endLine' in loc - && 'endColumn' in loc - && loc.endColumn > 0; + && 'endColumn' in loc; } export function isWholeFileLoc(loc: UrlValue): loc is WholeFileLocation {