Skip to content

Commit cbdd4b2

Browse files
committed
fix#23: the col is always 1
1 parent 6591015 commit cbdd4b2

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/extension.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,12 +268,19 @@ async function runCppcheckOnFileXML(
268268
continue;
269269
}
270270

271+
let col = Number(mainLoc.column) - 1;
272+
console.log('column # ', mainLoc);
273+
// Invalid line number usually means non-analysis output
274+
if (isNaN(col) || col < 0 || col > document.lineAt(line).text.length) {
275+
col = 1;
276+
}
277+
271278
const severity = parseSeverity(e.$.severity);
272279
if (severityToNumber(severity) < minSevNum) {
273280
continue;
274281
}
275282

276-
const range = new vscode.Range(line, 0, line, document.lineAt(line).text.length);
283+
const range = new vscode.Range(line, col, line, document.lineAt(line).text.length);
277284
const diagnostic = new vscode.Diagnostic(range, e.$.msg, severity);
278285
diagnostic.source = "cppcheck";
279286
diagnostic.code = e.$.id;

0 commit comments

Comments
 (0)