imc-trading / svlangserver

MIT License
100 stars 13 forks source link

Formatter issue #30

Open hankhsu1996 opened 2 years ago

hankhsu1996 commented 2 years ago

If I format a file with no trailing new line, the last line will be duplicated.

For example,

module my_module;
endmodule

Would become:

module my_module;
endmodule
endmodule
hankhsu1996 commented 2 years ago

BTW I use the default verible-verilog-format format command.

kkanhere commented 2 years ago

Can you please provide details about the editor you are using and the verible-verilog-format verison. Thanks

hankhsu1996 commented 2 years ago
$ verible-verilog-format --version 
v0.0-2152-gdd5e91a4
Commit  2022-05-23 14:53:23 -0700
Built   2022-05-23T22:18:27Z
$ code --version 
1.68.1
30d9c6cd9483b2cc586687151bcbcd635f373630
x64

I would guess it's line 65 in svformatter.ts. The formatter only replace from the first character in the file to the first character of the last line. However, I haven't tested it yet.

Maybe you can use Range(document.lineAt(0).range.start, document.lineAt(document.lineCount-1).range.end).

kkanhere commented 2 years ago

Thanks. I am able to reproduce the error. Looks like the output range is excluding the last line. Should be fixed in next release.