Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)

## [Unreleased]

### Changed

- Fix When running a linter through WSL, the file where the error occurred cannot be correctly indicated [#530](https://github.com/mshr-h/vscode-verilog-hdl-support/issues/530)

## [1.16.0] - 2025-01-23

### Added
Expand Down
18 changes: 16 additions & 2 deletions src/linter/VerilatorLinter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ export default class VerilatorLinter extends BaseLinter {
return child.execSync(cmd, {}).toString().replace(/\r?\n/g, '');
}

private convertFromWslPath(inputPath: string): string {
let cmd: string = `wsl wslpath -w '${inputPath}'`;
return child.execSync(cmd, {}).toString().replace(/\r?\n/g, '');
}

protected lint(doc: vscode.TextDocument) {
let docUri: string = isWindows
? this.useWSL
Expand Down Expand Up @@ -137,6 +142,11 @@ export default class VerilatorLinter extends BaseLinter {
}
}

// Remove superfluous NUL from line head
while (line.startsWith('\0')) {
line = line.slice(1);
}

// first line would be normal stderr output like "directory name is invalid"
// others are verilator sort of "highlighting" the issue, the block with "^~~~~"
// this can actually be used for better error/warning highlighting
Expand Down Expand Up @@ -204,9 +214,13 @@ export default class VerilatorLinter extends BaseLinter {
}

// replacing "\\" and "\" with "/" for consistency
if (isWindows)
{
if (isWindows) {
rex.groups["filePath"] = rex.groups["filePath"].replace(/(\\\\)|(\\)/g, "/");

// if WSL is used, convert the path to Windows format
if (this.useWSL) {
rex.groups["filePath"] = this.convertFromWslPath(rex.groups["filePath"]);
}
}

// if there isn't a list of errors for this file already, it
Expand Down