lkrms / vscode-inifmt

Trim and squeeze spaces and empty lines
MIT License
9 stars 2 forks source link

Modifies spaces inside the value #2

Open trailfog opened 1 year ago

trailfog commented 1 year ago

When formatting the following ini lines:

filename = filename  with  two  spaces.txt
format = "    [%s]  %s"

they get formatted the following:

filename = filename with two spaces.txt
format = " [%s] %s"

Removing multiple spaces before/after the equals symbol is fine, but it should leave them inside the value.

The same applies to the titles and key, where multiple consecutive spaces may be less desirable, but they should also be kept.

lkrms commented 1 year ago

Thanks for bringing this to my attention!

Definitely not the desired behaviour.

lkrms commented 7 months ago

Apologies for the delay fixing this; I had hoped to roll it into a rewrite and eliminate the awk dependency at the same time but haven't been able to prioritise it.

The update I've just released (v0.1.7) fixes the issue where spaces are collapsed between quotes (line 2 of your example), but unquoted spaces are still collapsed as per the extension's README ("replaces two or more consecutive spaces with one, unless they appear between double or single quotes on a single line").

I know internal whitespace within the value is significant for some .ini implementations, but didn't want to break the extension for users who rely on its current behaviour, especially when cleaning up files where = has no special meaning. I'm planning to make this and a few other .ini-specific behaviours available via configuration options and/or by scoping them exclusively to the .ini file type, but the rewrite needs to happen first.

Thanks again for reporting the issue!