Skip to content
This repository has been archived by the owner on Oct 14, 2023. It is now read-only.

Commit

Permalink
fix(library/module_mgr): ignore '\r' changes
Browse files Browse the repository at this point in the history
  • Loading branch information
gebner authored and Kha committed Jan 11, 2019
1 parent be4b782 commit 9282691
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/library/module_mgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,16 @@ module_mgr::build_lean_snapshots(std::shared_ptr<module_parser> const & mod_pars
}
}

static void remove_cr(std::string & str) {
str.erase(std::remove(str.begin(), str.end(), '\r'), str.end());
}

static bool equal_upto_cr(std::string a, std::string b) {
remove_cr(a);
remove_cr(b);
return a == b;
}

std::shared_ptr<module_info const> module_mgr::get_module(module_id const & id) {
unique_lock<mutex> lock(m_mutex);
name_set module_stack;
Expand All @@ -366,7 +376,9 @@ void module_mgr::invalidate(module_id const & id) {
bool rebuild_rdeps = true;
if (auto & mod = m_modules[id]) {
try {
if (m_vfs->load_module(id, false)->m_contents == mod->m_contents) {
// HACK(gabriel): On windows vscode sends different line endings than the on-disk version.
// This causes the server to recompile all files even when just hovering.
if (equal_upto_cr(m_vfs->load_module(id, false)->m_contents, mod->m_contents)) {
// content unchanged
rebuild_rdeps = false;
}
Expand Down

0 comments on commit 9282691

Please sign in to comment.