LaurentTreguier / vscode-uncrustify

Code format using uncrustify
66 stars 10 forks source link

"Upgrade Config File" command dangerously overwrites global default file #7

Closed dsifford closed 7 years ago

dsifford commented 7 years ago

Hi there,

This might be the intended function of the Upgrade Config File command, but that's not explicitly stated (or if it is, it's not immediately evident). Earlier today I executed that command because I wanted to quickly tweak a setting in my global file and I was rudely awoken by my config file being completely reset, which was a soul-shattering mistake on my end. 😢

Anyway, consider this issue a drop in the suggestion bin that this function should be changed or, at the very least, a confirm warning should be displayed before this happens.

Thanks so much in advance! 😄

LaurentTreguier commented 7 years ago

This is clearly a bug... Upgrading the file is supposed to read the config, download the new file, and write the config you had on top of it. The file should not be reset by this.

Did you use the default name for the config file (uncrustify.cfg)? What version of uncrustify are you using?

But I fear I realized what might cause this : did you use a custom file you already had prior to using this extension?

dsifford commented 7 years ago

Thanks for the quick reply @LaurentTreguier 😄

My global config file (and the one that your extension points to) is located at ~/.dotfiles/uncrustify.cfg, but it is also symlinked to the canonical ~/.uncrustify.cfg location for automatic CLI usage.

What version of uncrustify are you using?

Uncrustify-0.65_f

But I fear I realized what might cause this : did you use a custom file you already had prior to using this extension?

Correct.

Let me know if I can clarify anything else. Thanks again!

LaurentTreguier commented 7 years ago

@dsifford Actually, it's something really dumb. You mentioned you used the Upgrade Config File command, which is not supposed to be used manually. I'll put safeguards on all commands to prevent weird things like this one from happening.

dsifford commented 7 years ago

Haha, well that makes sense. I have a habit of doing dumb things! 😝

Is there a way to open up the global file for editing using the extension? If not, can that maybe be added in?

Thanks!

LaurentTreguier commented 7 years ago

Is there a way to open up the global file for editing using the extension ?

What do you mean by 'global file for editing' ?

dsifford commented 7 years ago

The ~/.uncrustify.cfg file. Not a project-level file.

LaurentTreguier commented 7 years ago

With this commit I added a command to open the currenlty used config file. So ~/.uncrustify.cfg can be set in the extension config and can be opened from any project directory afterwards

LaurentTreguier commented 7 years ago

Or did you want to be able to open it even when having a project specific config file ?

dsifford commented 7 years ago

@LaurentTreguier Nope, you totally nailed it. Thanks so much! 🎉