vlang / vscode-vlang

V Language extension for Visual Studio Code.
MIT License
386 stars 52 forks source link

v.fmt does not work if there is syntax error in the file #531

Closed felixf4xu closed 1 year ago

felixf4xu commented 1 year ago

Hi,

I'm testing this extension and I found that if the .v source file contains syntax error, v.fmt will not work: the command just exits silently without formatting the file, and there is no error message.

how to reproduce:

create a .v file with syntax error, then ctrl+shift+p to execute v.fmt command.

Expected behavior:

the file is formatted or there is error message.

Others

I checked the source code a little bit:

export async function fmt(): Promise<void> {
    const document = window.activeTextEditor.document;
    await document.save();
    const filePath = `"${document.fileName}"`;

    execVInTerminalOnBG(['fmt', '-w', filePath]);
}

execVInTerminalOnBG should be execVInTerminal and then there will be error message if the file contains syntax error.