Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detect compile_commands.json after containing folder deleted and recreated on Windows #13032

Merged
merged 3 commits into from
Dec 11, 2024

Conversation

yiftahw
Copy link
Contributor

@yiftahw yiftahw commented Dec 8, 2024

closes #7030
On my setup (Windows 10 Home 22H2), when a folder is copied, it's containing files' stats.mtime remain the same (even though the containing folder's stats are new), which is the root cause of this issue.
For comparison on my WSL (Ubuntu 20.04 LTS), the new files' stats.mtime will be the time when the copied files were created.
The fix adds the check if the compileCommandsFile is undefined | null which means it was previously not "present".

note: a side effect of this fix is that on every initial load of a workspace, (if fs.stats didn't return an error) we fire the onCompileCommandsChanged event because CppProperties.compileCommandsFile is initially marked as undefined.
if we remove the undefined case from the condition check, the fix will only work if the compileCommandsFile was actually changed at least once (since the workspace was loaded) before the containing folder is deleted and re-created.

cases tested:

  • containing folder deleted after workspace was loaded, and copied back on a Windows machine. (the issue, tested on Linux as well)
  • containing folder doesn't exist and copied back after workspace was loaded on a Windows machine. (the issue, tested on Linux as well)
  • compile_commands.json file deleted after workspace was loaded and re-created (with a new timestamp)
  • compile_commands.json doesn't exist and generated after workspace is loaded.

@yiftahw yiftahw requested a review from a team as a code owner December 8, 2024 08:24
@yiftahw yiftahw changed the title Fix for issue #7030 Detect compile_commands.json after containing folder deleted and recreated on Windows Dec 10, 2024
@sean-mcmanus sean-mcmanus requested review from Colengms and a team December 10, 2024 18:06
Copy link
Member

@fearthecowboy fearthecowboy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me

@sean-mcmanus sean-mcmanus merged commit d04d53e into microsoft:main Dec 11, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

compile_commands.json is no longer used if containing folder is deleted and recreated
4 participants