@@ -6,6 +6,7 @@ module workspaced.com.ccdb;
66import std.exception ;
77import std.json ;
88import std.path ;
9+ import std.string ;
910import fs = std.file ;
1011
1112import workspaced.api;
@@ -144,7 +145,7 @@ class ClangCompilationDatabaseComponent : ComponentWrapper
144145 // / in the database.
145146 CompileCommand getCompileCommand (string filename) @property
146147 {
147- auto normalized = buildNormalizedPath (filename);
148+ const normalized = normalizedCcdbPath (filename);
148149 auto ccp = normalized in _compileCommands;
149150 if (ccp)
150151 return * ccp;
@@ -171,8 +172,10 @@ public class CompileCommand
171172 import std.algorithm : map;
172173 import std.array : array;
173174
174- this .directory = enforce(" directory" in json, " 'directory' missing from Clang compilation database entry" )
175- .str;
175+ this .directory = normalizedCcdbPath(
176+ enforce(" directory" in json, " 'directory' missing from Clang compilation database entry" )
177+ .str
178+ );
176179 this .file = enforce(" file" in json, " 'file' missing from Clang compilation database entry" )
177180 .str;
178181
@@ -209,7 +212,7 @@ public class CompileCommand
209212
210213 string getNormalizedFilePath () const
211214 {
212- return getPath (file).buildNormalizedPath( );
215+ return normalizedCcdbPath ( getPath(file));
213216 }
214217
215218 string getPath (string filename) const
@@ -303,6 +306,17 @@ public class CompileCommand
303306 }
304307}
305308
309+ string normalizedCcdbPath (string filePath)
310+ {
311+ const normalized = filePath.buildNormalizedPath();
312+ // Let the drive be lower case on Windows (not handled by buildNormalizedPath).
313+ // This is needed because commands are resolved by simple string comparison.
314+ version (Windows )
315+ return driveName (normalized).toLower() ~ stripDrive(normalized);
316+ else
317+ return normalized;
318+ }
319+
306320void feedOptions (
307321 in CompileCommand cc,
308322 ref HashSet! string imports,
0 commit comments