franneck94 / Vscode-C-Cpp-Runner

🚀 Compile, run and debug single or multiple C/C++ files with ease. 🚀
MIT License
55 stars 14 forks source link

[BUG] Extension constantly updates .vscode/settings.json #152

Closed Gotoro closed 6 months ago

Gotoro commented 6 months ago

https://github.com/franneck94/Vscode-C-Cpp-Runner/assets/39387797/401176d8-c9e1-4790-90e4-0d75a17b802f

I have bare minimum of extensions enabled:

I can't disable anything else as they depend on each other. When in a workspace, having .c file open creates 3 files in .vscode subdirectory: c_cpp_properties.json, launch.json and settings.json

I'm having problems with the settings.json file. Having it open (update: it doesn't matter if it's open or not) seemingly causes it to update all the time(see video), without letting me do any changes to it, while causing a lot of writes to the disk. Opening a new project does not fix the issue. If you could provide the help to debug this further, that would be appreciated.

Gotoro commented 6 months ago

image It appears the issue is not new?

Gotoro commented 6 months ago

okay so in my case while loading the initial local settings in settingsProvider.ts, the msvcBatchPath is empty so it falls back to DEFAULT_MSVC_BATCH_PATH and tries to find the folder to msvc. After failing to do so it updates the file with the empty value for msvcBatchPath.

Now the bug starts at the changeCallback function which gets called by the vscode watcher watching all files in .vscode/**. As the file was just changed now the function actually calls loadLocalSettings again, starting the infinite loop.

I'm not 100% sure if this is what's happening but that's what I got. I'll follow with a pr shortly

franneck94 commented 6 months ago

Needs to be fixed by some other way

franneck94 commented 6 months ago

To reproduce this, you dont have msvc installed right?

Gotoro commented 6 months ago

Hello. So, correct, the msvc is not installed per se, a remnant folder is still there but it's empty (it was installed at some time before), shared folder on a screenshot is empty too. image

At this point, on the first loop of the bug the msvc path is this image Not sure where the the actual path comes from, ie where it's stored, but it gets the one in the screenshot. Then it goes through what I described. To reiterate, this path does not exist, it falls through to else clause where it sets it to empty which causes the file update which causes the infinite loop.

If you could come up with the way to fix, please do, I really enjoy your extension, as I finally got into c programming a few days ago and your extension seems like the way to go. I'm surprised this doesn't get more traction here on github

Gotoro commented 6 months ago

To add to this, even with the proposed fix, it seems a different issue occurs where an update to a config file causes the watcher to detect change multiple times (16 on a video). Maybe I'm misunderstanding something and it's supposed to work like that, but discovered this while testing. This doesn't cause any apparent problems as it seems, but maybe enough to open a different issue?

On video, changing launch.json somehow fires console.log multiple times:

https://github.com/franneck94/Vscode-C-Cpp-Runner/assets/39387797/04be6665-9fde-4a19-9f5e-110beea5b3e8

franneck94 commented 6 months ago

Can you try the branch bug/infLoopMsvc' Should be fixed there

Gotoro commented 6 months ago

Yes, the issue appears to be fixed with the mentioned commit. Thank you!