Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed issues reported in #170 #203

Merged
merged 1 commit into from
Aug 18, 2023
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ More details can be found on the [Releases](https://github.com/eirikpre/VSCode-S
- 💡 Back-end Language Server for Systemverilog
- 💡 Complete syntax highlighting

### [NEXT_RELEASE]

- Improved format command parsing and error handling per issue #170 `joecrop`

### [0.13.4]

- Updated Verible lint regular expressions for new output format by `joecrop`
Expand Down
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,35 @@ Use the provided settings in a user or workspace `settings.json` as appropriate.
}
```

### Handling Spaces In Executable Paths

Please exercise caution when setting an executable path in the settings, such as the case with `systemverilog.formatCommand`, `systemverilog.launchConfigurationVerilator`, `systemverilog.launchConfigurationVCS`, and `systemverilog.launchConfigurationVerible`. Any spaces will be assumed to be arguments and not the executable itself. In Windows, for example, you might have an executable configured as follows:

```json
"systemverilog.formatCommand" : "C:\\Program Files\\verible\\bin\\verible-verilog-format --case_items_alignment=infer"
```

Because of the space in 'Program Files', the extension will infer that the executable is `C:\\Program` with two arguments: `Files\\verible\\bin\\verible-verilog-format` and `--case_items_alignment=infer`. This breaks the executable path. There are a couple solutions for tihs:

1. (Prefered) Add the executable to your PATH and call it directly.
- [Windows instructions](https://www.computerhope.com/issues/ch000549.htm)
- [Linux Instructions](https://phoenixnap.com/kb/linux-add-to-path)
- [Mac Instructions](https://www.architectryan.com/2012/10/02/add-to-the-path-on-mac-os-x-mountain-lion/#.Uydjga1dXDg)

```json
"systemverilog.formatCommand" : "verible-verilog-format --case_items_alignment=infer"
```

2. If you can't edit your path (maybe because of privileges), then don't use spaces in paths. Either move the executable to a different location with no spaces, or (in the case of windows) you can use [DOS short names](https://superuser.com/questions/348079/how-can-i-find-the-short-path-of-a-windows-directory-file) as follows:

```json
"systemverilog.formatCommand" : "C:\\PROGRA~1\\verible\\bin\\verible-verilog-format --case_items_alignment=infer"
```





## Known Issues

- Initial indexing might hog CPU/RAM when looking through files in very large workspaces
Expand Down
8 changes: 3 additions & 5 deletions src/providers/FormatProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export class SystemVerilogFormatProvider implements vscode.DocumentFormattingEdi
const codeContent = document.getText();

const formatArgs = [];
const userArgs = formatCommand.split(/\s+/);
const userArgs = formatCommand.trim().split(/\s+/);
const executable = userArgs[0];
if (userArgs.length > 1) {
formatArgs.push(...userArgs.slice(1));
Expand Down Expand Up @@ -91,17 +91,15 @@ export class SystemVerilogFormatProvider implements vscode.DocumentFormattingEdi
});
child.on('error', (err) => {
if (err && (<any>err).code === 'ENOENT') {
vscode.window.showInformationMessage(`The '${formatCommand}' command is not available.`);
vscode.window.showInformationMessage(`The '${executable}' command is not available.`);
return resolve(null);
}
return reject(err);
});
child.on('close', (code) => {
try {
if (stderr.length !== 0) {
this.outputChannel.show();
this.outputChannel.clear();
this.outputChannel.appendLine(stderr);
vscode.window.showInformationMessage(stderr);
return reject(new Error('Cannot format due to syntax errors.'));
}

Expand Down
3 changes: 2 additions & 1 deletion verilog-examples/.vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"systemverilog.disableIndexing": true,
"systemverilog.documentSymbolsPrecision": "full",
"editor.tabSize": 2,
"files.eol": "\n"
"files.eol": "\n",
"systemverilog.formatCommand": "C:\\Program Files\\Git\\bin\\git.exe"
}