diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2020-11-25 17:17:18 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2020-11-25 17:17:18 +0800 |
commit | 9e7944e17041f573729c57b2c3b5d711c63d6e32 (patch) | |
tree | 55bff8fb32325f66b5bf6f8b07d108ed982be6f5 /script/workspace | |
parent | 33580c1dd7c5ce0c9829e976cacd94418846eece (diff) | |
download | lua-language-server-9e7944e17041f573729c57b2c3b5d711c63d6e32.zip |
fix path
Diffstat (limited to 'script/workspace')
-rw-r--r-- | script/workspace/require-path.lua | 6 | ||||
-rw-r--r-- | script/workspace/workspace.lua | 4 |
2 files changed, 6 insertions, 4 deletions
diff --git a/script/workspace/require-path.lua b/script/workspace/require-path.lua index cfdc0455..9004b39c 100644 --- a/script/workspace/require-path.lua +++ b/script/workspace/require-path.lua @@ -44,9 +44,11 @@ function m.getVisiblePath(path, searchers) pos = path:match('[/\\]+()', pos) for _, searcher in ipairs(searchers) do if platform.OS == 'Windows' then - searcher = searcher:gsub('[/\\]+', '\\') + searcher = searcher :gsub('[/\\]+', '\\') + :gsub('^[/\\]+', '') else - searcher = searcher:gsub('[/\\]+', '/') + searcher = searcher :gsub('[/\\]+', '/') + :gsub('^[/\\]+', '') end local expect = getOnePath(cutedPath, searcher) if expect then diff --git a/script/workspace/workspace.lua b/script/workspace/workspace.lua index f5431def..13208b75 100644 --- a/script/workspace/workspace.lua +++ b/script/workspace/workspace.lua @@ -320,9 +320,9 @@ function m.getRelativePath(uri) _, pos = m.normalize(path):find(m.path, 1, true) end if pos then - return m.normalize(path:sub(pos + 1)) + return m.normalize(path:sub(pos + 1)):gsub('^[/\\]+', '') else - return m.normalize(path) + return m.normalize(path):gsub('^[/\\]+', '') end end |