Skip to content

Commit 31c8be2

Browse files
committed
fix vscode.Position api usage bug
1 parent 1be0085 commit 31c8be2

3 files changed

Lines changed: 12 additions & 5 deletions

File tree

src/EIDEProjectExplorer.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3440,7 +3440,7 @@ export class ProjectExplorer implements CustomConfigurationProvider {
34403440
context.subscriptions.push(vscode.commands.registerCommand(ProjTreeItem.ITEM_CLICK_EVENT, (item) => this.OnTreeItemClick(item)));
34413441

34423442
// create vsc output channel
3443-
this.cppcheck_out = vscode.window.createOutputChannel('eide-cppcheck');
3443+
this.cppcheck_out = vscode.window.createOutputChannel('eide-static-check-log');
34443444
this.cppToolsOut = vscode.window.createOutputChannel('eide-cpptools-log');
34453445

34463446
// register doc event
@@ -5754,8 +5754,11 @@ export class ProjectExplorer implements CustomConfigurationProvider {
57545754
const diags = Array.from(this.cppcheck_diag.get(uri) || []);
57555755
const line = parseInt(mRes[pattern.line]);
57565756
const col = parseInt(mRes[pattern.column]);
5757-
const pos = new vscode.Position(line - 1, col - 1);
5758-
const diag = new vscode.Diagnostic(new vscode.Range(pos, pos), mRes[pattern.message], toVscServerity(mRes[pattern.severity]));
5757+
const col_s = col > 0 ? (col - 1) : 0;
5758+
const range = new vscode.Range(
5759+
new vscode.Position(line - 1, col_s),
5760+
new vscode.Position(line - 1, col_s + 10));
5761+
const diag = new vscode.Diagnostic(range, mRes[pattern.message], toVscServerity(mRes[pattern.severity]));
57595762
diag.source = 'cppcheck';
57605763
diags.push(diag);
57615764
this.cppcheck_diag.set(uri, diags);
@@ -5780,6 +5783,7 @@ export class ProjectExplorer implements CustomConfigurationProvider {
57805783
GlobalEvent.emit('msg', ExceptionToMessage(err));
57815784
});
57825785

5786+
this.cppcheck_out.append(`>>> Exec cppcheck\n -> ${exeFile.name} ${cmds.join(' ')}\n\n`);
57835787
process.Run(exeFile.name, cmds, opts);
57845788
});
57855789
});

src/ProblemMatcher.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ function toVscServerity(str_: string): vscode.DiagnosticSeverity {
8787
}
8888

8989
function newVscFilePosition(toolchain: ToolchainName, line: number, col?: number): vscode.Position {
90+
if (col != undefined && col < 0)
91+
col = 0;
9092
switch (toolchain) {
9193
default:
9294
return new vscode.Position(line > 0 ? (line - 1) : 0, col || 0);

src/WebPanelManager.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -388,8 +388,9 @@ export class WebPanelManager {
388388
switch (data.cmd) {
389389
case 'open-config':
390390
{
391-
const pos = new vscode.Position(data.arg, data.arg);
392-
vscode.window.showTextDocument(uri, { preview: true, selection: new vscode.Range(pos, pos) });
391+
const pos_s = new vscode.Position(data.arg, 0);
392+
const pos_e = new vscode.Position(data.arg, 300);
393+
vscode.window.showTextDocument(uri, { preview: true, selection: new vscode.Range(pos_s, pos_e) });
393394
}
394395
break;
395396
default:

0 commit comments

Comments
 (0)