From 92826917a252a6092cffaf5fc5f1acb1f8cef379 Mon Sep 17 00:00:00 2001 From: Gabriel Ebner Date: Thu, 10 Jan 2019 09:29:29 +0100 Subject: [PATCH] fix(library/module_mgr): ignore '\r' changes --- src/library/module_mgr.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/library/module_mgr.cpp b/src/library/module_mgr.cpp index bfa5958523..cd8d88ec6a 100644 --- a/src/library/module_mgr.cpp +++ b/src/library/module_mgr.cpp @@ -353,6 +353,16 @@ module_mgr::build_lean_snapshots(std::shared_ptr 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_mgr::get_module(module_id const & id) { unique_lock lock(m_mutex); name_set module_stack; @@ -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; }