Skip to content

[BUG] The formatter cannot be worked without workspaceFolders #521

Open
@UrMyLacia

Description

@UrMyLacia

Describe the bug
A clear and concise description of what the bug is.

Environment (please complete the following information):

  • OS: Windows 11 24H2 build 26100.3915]
  • VS Code version 1.99.3
  • Extension version 1.16.0
  • verible-verilog-format v0.0-3973-g904f446f

Steps to reproduce
Steps to reproduce the behavior:

Directly open vscode and then open the file
Directly open vscode and create a new v/sv File
Use code [PathToFile] to open
Etc.
In summary, the situation is that execute Formatter without workspaceFolders

Log
Output -> Verilog

2025-04-29 19:44:20.974 [info] [SystemVerilogFormatProvider] Temp file created at:C:\Path\To\Temp\veribleVerilogFormatter-fc9e776196dbce107afd4e585f300c03.tmp.sv
2025-04-29 19:44:20.974 [info] [SystemVerilogFormatProvider] Executing command: verible-verilog-format --inplace C:\Path\To\Temp\veribleVerilogFormatter-fc9e776196dbce107afd4e585f300c03.tmp.sv
2025-04-29 19:44:20.974 [error] [SystemVerilogFormatProvider] TypeError: Cannot read properties of undefined (reading '0')

Expected behavior
Format should be executed

Actual behavior
No changes

Causes of the problem
I tracked the and the problem stemmed from no workspace in variable workspaceFolders

child_process.execFileSync(binPath, args, {cwd: vscode.workspace.workspaceFolders[0].uri.fsPath});

If vscode is not opened in the worksapce, workspaceFolders cannot be indexed
The last commit of this file caused this problem. Perhaps we should check whether workspace exists in workspaceFolders

By the way, why not print the stack information in the catch? (Maybe I haven't found how to view it)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions