From 274cd6b326ca6be0da65ebde79f8c48c83bc406b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Mon, 28 Sep 2020 02:43:52 +0800 Subject: =?UTF-8?q?hover=E4=B9=9F=E6=98=BE=E7=A4=BA=E6=8E=A8=E6=B5=8B?= =?UTF-8?q?=E7=9A=84=E6=90=9C=E7=B4=A2=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script-beta/core/hover/description.lua | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'script-beta/core/hover/description.lua') diff --git a/script-beta/core/hover/description.lua b/script-beta/core/hover/description.lua index 63c5afae..af6ad608 100644 --- a/script-beta/core/hover/description.lua +++ b/script-beta/core/hover/description.lua @@ -7,6 +7,7 @@ local markdown = require 'provider.markdown' local config = require 'config' local client = require 'provider.client' local lang = require 'language' +local platform = require 'bee.platform' local function asString(source) local literal = guide.getLiteral(source) @@ -15,7 +16,7 @@ local function asString(source) end local parent = source.parent if parent and parent.type == 'callargs' then - local result + local result, searchers local call = parent.parent local func = call.node local lib = vm.getLibrary(func) @@ -23,20 +24,27 @@ local function asString(source) return end if lib.name == 'require' then - result = ws.findUrisByRequirePath(literal) + result, searchers = ws.findUrisByRequirePath(literal) elseif lib.name == 'dofile' or lib.name == 'loadfile' then result = ws.findUrisByFilePath(literal) end if result and #result > 0 then for i, uri in ipairs(result) do + 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) end path = path:gsub('^[/\\]*', '') - result[i] = ('* [%s](%s)'):format(path, uri) + if searcher then + searcher = ws.normalize(searcher) + searcher = searcher:sub(#ws.path + 1) + result[i] = ('* [%s](%s) (假设搜索路径包含 `%s`)'):format(path, uri, searcher) + else + result[i] = ('* [%s](%s)'):format(path, uri) + end end table.sort(result) return table.concat(result, '\n') -- cgit v1.2.3