From 2c6f8dbd7e5adc732c0d679351b2a18d025c650b Mon Sep 17 00:00:00 2001 From: erw7 Date: Thu, 21 Nov 2019 13:41:14 +0900 Subject: Fix iterate_parents infinite loop on Windows (#42) - Fix the problem that Windows identification fails because uv.os_uname().sysname is different between MSVC(Windows_NT) and MINGW(MINGW32_NT-XX.X). - Fixes an issue where is_fs_root() does not return true in the root directory because dirname() returns a value (such as C:) that does not include the last path_sep. - Fix problem where path_join('/', 'home') return '//home'. --- lua/nvim_lsp/util.lua | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'lua/nvim_lsp/util.lua') diff --git a/lua/nvim_lsp/util.lua b/lua/nvim_lsp/util.lua index 70d8c823..407088cd 100644 --- a/lua/nvim_lsp/util.lua +++ b/lua/nvim_lsp/util.lua @@ -114,13 +114,13 @@ M.path = (function() return exists(filename) == 'file' end - local is_windows = uv.os_uname().sysname == "Windows" + local is_windows = uv.os_uname().version:match("Windows") local path_sep = is_windows and "\\" or "/" local is_fs_root if is_windows then is_fs_root = function(path) - return path:match("^%a:\\\\$") + return path:match("^%a:$") end else is_fs_root = function(path) @@ -143,7 +143,10 @@ M.path = (function() end local function path_join(...) - return table.concat(vim.tbl_flatten {...}, path_sep) + local result = + table.concat( + vim.tbl_flatten {...}, path_sep):gsub(path_sep.."+", path_sep) + return result end -- Traverse the path calling cb along the way. -- cgit v1.2.3-70-g09d2