Skip to content

Commit e7c917c

Browse files
authored
fix #9: diagnosis for header files shown in source code files with incorrect references (#18)
1 parent 0b45cbe commit e7c917c

File tree

2 files changed

+112
-32
lines changed

2 files changed

+112
-32
lines changed

package-lock.json

Lines changed: 106 additions & 32 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/extension.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,12 @@ async function runCppcheckOnFileXML(
258258

259259
// Cppcheck line number is 1-indexed, while VS Code uses 0-indexing
260260
const mainLoc = locations[locations.length - 1].$;
261+
262+
// If main location is not current file, then skip displaying warning
263+
if (!filePath.endsWith(mainLoc.file)) {
264+
continue;
265+
}
266+
261267
const line = Number(mainLoc.line) - 1;
262268
// Invalid line number usually means non-analysis output
263269
if (isNaN(line) || line < 0 || line >= document.lineCount) {

0 commit comments

Comments
 (0)