Skip to content
This repository has been archived by the owner on Jul 30, 2020. It is now read-only.

Commit

Permalink
Another attempt at fixing #543
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobdufault committed May 13, 2018
1 parent 11f9542 commit e1e2028
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/lsp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ struct UriCache {
// If we do not have the value in the cache, try to renormalize it.
// Otherwise we will return paths with all lower-case letters which may
// break vscode.
optional<AbsolutePath> normalized = NormalizePath(path.path);
optional<AbsolutePath> normalized = NormalizePath(path.path, true /*ensure_exists*/, false /*force_lower_on_windows*/);
if (normalized)
return normalized->path;

Expand Down
3 changes: 2 additions & 1 deletion src/platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ void PlatformInit();
AbsolutePath GetExecutablePath();
AbsolutePath GetWorkingDirectory();
optional<AbsolutePath> NormalizePath(const std::string& path,
bool ensure_exists = true);
bool ensure_exists = true,
bool force_lower_on_windows = true);

// Creates a directory at |path|. Creates directories recursively if needed.
void MakeDirectoryRecursive(const AbsolutePath& path);
Expand Down
3 changes: 2 additions & 1 deletion src/platform_posix.cc
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,8 @@ AbsolutePath GetWorkingDirectory() {
}

optional<AbsolutePath> NormalizePath(const std::string& path,
bool ensure_exists) {
bool ensure_exists,
bool force_lower_on_windows) {
return RealPathNotExpandSymlink(path, ensure_exists);
}

Expand Down
9 changes: 6 additions & 3 deletions src/platform_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ AbsolutePath GetWorkingDirectory() {
}

optional<AbsolutePath> NormalizePath(const std::string& path0,
bool ensure_exists) {
bool ensure_exists,
bool force_lower_on_windows) {
// Requires Windows 8
/*
if (!PathCanonicalize(buffer, path.c_str()))
Expand Down Expand Up @@ -99,8 +100,10 @@ optional<AbsolutePath> NormalizePath(const std::string& path0,
path[0] = toupper(path[0]);
*/
// Make the path all lower-case, since windows is case-insensitive.
for (size_t i = 0; i < path.size(); ++i)
path[i] = (char)tolower(path[i]);
if (force_lower_on_windows) {
for (size_t i = 0; i < path.size(); ++i)
path[i] = (char)tolower(path[i]);
}

// cquery assumes forward-slashes.
std::replace(path.begin(), path.end(), '\\', '/');
Expand Down

0 comments on commit e1e2028

Please sign in to comment.