Skip to content

Commit 3bb6b27

Browse files
committed
updated fallback value and incorrect comments
1 parent dd71626 commit 3bb6b27

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/extension.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,23 +254,24 @@ async function runCppcheckOnFileXML(
254254
continue;
255255
}
256256

257-
// Cppcheck line number is 1-indexed, while VS Code uses 0-indexing
258257
const mainLoc = locations[locations.length - 1].$;
259258

260259
// If main location is not current file, then skip displaying warning
261260
if (!filePath.endsWith(mainLoc.file)) {
262261
continue;
263262
}
264263

264+
// Cppcheck line number is 1-indexed, while VS Code uses 0-indexing
265265
const line = Number(mainLoc.line) - 1;
266266
// Invalid line number usually means non-analysis output
267267
if (isNaN(line) || line < 0 || line >= document.lineCount) {
268268
continue;
269269
}
270270

271+
// Cppcheck col number is 1-indexed, while VS Code uses 0-indexing
271272
let col = Number(mainLoc.column) - 1;
272273
if (isNaN(col) || col < 0 || col > document.lineAt(line).text.length) {
273-
col = 1;
274+
col = 0;
274275
}
275276

276277
const severity = parseSeverity(e.$.severity);

0 commit comments

Comments
 (0)