From d04d53e9a6326415e602e8b04b5bc4910a646e5b Mon Sep 17 00:00:00 2001 From: Yiftah Waisman <63462505+yiftahw@users.noreply.github.com> Date: Thu, 12 Dec 2024 01:35:00 +0200 Subject: [PATCH] Detect compile_commands.json after containing folder deleted and recreated on Windows (#13032) * fix issue #7030 * check for the undefined case (on first load) --- Extension/src/LanguageServer/configurations.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Extension/src/LanguageServer/configurations.ts b/Extension/src/LanguageServer/configurations.ts index 6f23eb3479..028cc7235c 100644 --- a/Extension/src/LanguageServer/configurations.ts +++ b/Extension/src/LanguageServer/configurations.ts @@ -2340,7 +2340,9 @@ export class CppProperties { } } else { const compileCommandsLastChanged: Date | undefined = this.compileCommandsFileWatcherFallbackTime.get(compileCommandsFile); - if (compileCommandsLastChanged !== undefined && stats.mtime > compileCommandsLastChanged) { + if ((this.compileCommandsFile === undefined) || + (this.compileCommandsFile === null) || + (compileCommandsLastChanged !== undefined && stats.mtime > compileCommandsLastChanged)) { this.compileCommandsFileWatcherFallbackTime.set(compileCommandsFile, new Date()); this.onCompileCommandsChanged(compileCommandsFile); this.compileCommandsFile = vscode.Uri.file(compileCommandsFile); // File created.