diff options
-rw-r--r-- | script-beta/core/hover/description.lua | 7 | ||||
-rw-r--r-- | script-beta/workspace/workspace.lua | 3 | ||||
-rw-r--r-- | test-beta.lua | 1 |
3 files changed, 8 insertions, 3 deletions
diff --git a/script-beta/core/hover/description.lua b/script-beta/core/hover/description.lua index a3c9429f..dd04373e 100644 --- a/script-beta/core/hover/description.lua +++ b/script-beta/core/hover/description.lua @@ -11,6 +11,7 @@ local platform = require 'bee.platform' local library = require 'library' local function asStringInRequire(source, literal) + local rootPath = ws.path or '' local parent = source.parent if parent and parent.type == 'callargs' then local result, searchers @@ -31,14 +32,14 @@ local function asStringInRequire(source, literal) local searcher = searchers and furi.decode(searchers[uri]) uri = files.getOriginUri(uri) local path = furi.decode(uri) - if files.eq(path:sub(1, #ws.path), ws.path) then - path = path:sub(#ws.path + 1) + if files.eq(path:sub(1, #rootPath), rootPath) then + path = path:sub(#rootPath + 1) end path = path:gsub('^[/\\]*', '') if vm.isMetaFile(uri) then result[i] = ('* [[meta]](%s)'):format(uri) elseif searcher then - searcher = searcher:sub(#ws.path + 1) + searcher = searcher:sub(#rootPath + 1) searcher = ws.normalize(searcher) result[i] = ('* [%s](%s) %s'):format(path, uri, lang.script('HOVER_USE_LUA_PATH', searcher)) else diff --git a/script-beta/workspace/workspace.lua b/script-beta/workspace/workspace.lua index ec7af5da..a4acac79 100644 --- a/script-beta/workspace/workspace.lua +++ b/script-beta/workspace/workspace.lua @@ -298,6 +298,9 @@ end function m.getRelativePath(uri) local path = furi.decode(uri) + if not m.path then + return m.normalize(path) + end local _, pos = m.normalize(path):lower():find(m.path:lower(), 1, true) if pos then return m.normalize(path:sub(pos + 1)) diff --git a/test-beta.lua b/test-beta.lua index 14d07650..d90034dd 100644 --- a/test-beta.lua +++ b/test-beta.lua @@ -32,6 +32,7 @@ local function loadDocMetas() local library = require 'library' local furi = require 'file-uri' local fsu = require 'fs-utility' + library.init() for _, path in ipairs(library.metaPaths) do local uri = furi.encode(path) files.setText(uri, fsu.loadFile(path)) |