Detect compile_commands.json after containing folder deleted and recreated on Windows #13032
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
isundefined | 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 theonCompileCommandsChanged
event becauseCppProperties.compileCommandsFile
is initially marked asundefined
.if we remove the
undefined
case from the condition check, the fix will only work if thecompileCommandsFile
was actually changed at least once (since the workspace was loaded) before the containing folder is deleted and re-created.cases tested:
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.