diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2020-12-07 09:55:24 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2020-12-07 09:55:31 +0800 |
commit | 3238be9f9828d3728fb81e2284ac2a5c2c9b3208 (patch) | |
tree | 704453298c91800648ac580a97dec332884981be /script/workspace | |
parent | 48c7a420e07fff03a88542c3b22f6f61b3cfc95b (diff) | |
download | lua-language-server-3238be9f9828d3728fb81e2284ac2a5c2c9b3208.zip |
update auto require
Diffstat (limited to 'script/workspace')
-rw-r--r-- | script/workspace/require-path.lua | 10 | ||||
-rw-r--r-- | script/workspace/workspace.lua | 2 |
2 files changed, 6 insertions, 6 deletions
diff --git a/script/workspace/require-path.lua b/script/workspace/require-path.lua index 3ec2d6d1..f1dc2fb9 100644 --- a/script/workspace/require-path.lua +++ b/script/workspace/require-path.lua @@ -1,6 +1,7 @@ local platform = require 'bee.platform' local files = require 'files' local furi = require 'file-uri' +local workspace = require "workspace" local m = {} m.cache = {} @@ -24,7 +25,7 @@ local function getOnePath(path, searcher) return nil end -function m.getVisiblePath(path, searchers) +function m.getVisiblePath(path, searchers, strict) path = path:gsub('^[/\\]+', '') local uri = furi.encode(path) local libraryPath = files.getLibraryPath(uri) @@ -35,6 +36,8 @@ function m.getVisiblePath(path, searchers) if libraryPath then libraryPath = libraryPath:gsub('^[/\\]+', '') pos = #libraryPath + 2 + else + path = workspace.getRelativePath(uri) end repeat local cutedPath = path:sub(pos) @@ -62,10 +65,7 @@ function m.getVisiblePath(path, searchers) } end end - if not pos then - break - end - until not pos + until not pos or strict end return m.cache[path] end diff --git a/script/workspace/workspace.lua b/script/workspace/workspace.lua index a6425a8b..c76eec55 100644 --- a/script/workspace/workspace.lua +++ b/script/workspace/workspace.lua @@ -6,7 +6,6 @@ local config = require 'config' local glob = require 'glob' local platform = require 'bee.platform' local await = require 'await' -local rpath = require 'workspace.require-path' local proto = require 'proto.proto' local lang = require 'language' local library = require 'library' @@ -359,6 +358,7 @@ function m.getRelativePath(uri) end function m.reload() + local rpath = require 'workspace.require-path' files.flushAllLibrary() files.removeAllClosed() files.flushCache() |