diff options
-rw-r--r-- | script/core/completion.lua | 14 | ||||
-rw-r--r-- | script/core/hover/description.lua | 6 | ||||
-rw-r--r-- | script/core/hover/label.lua | 1 | ||||
-rw-r--r-- | script/provider/markdown.lua | 4 | ||||
-rw-r--r-- | script/provider/provider.lua | 8 | ||||
-rw-r--r-- | test/completion/init.lua | 3 | ||||
-rw-r--r-- | test/crossfile/completion.lua | 4 | ||||
-rw-r--r-- | test/crossfile/hover.lua | 3 |
8 files changed, 28 insertions, 15 deletions
diff --git a/script/core/completion.lua b/script/core/completion.lua index ba480451..d4f77368 100644 --- a/script/core/completion.lua +++ b/script/core/completion.lua @@ -197,7 +197,7 @@ local function buildDesc(source) md:add('md', hover.description) md:splitLine() md:add('lua', getSnip(source)) - return md:string() + return md end local function buildFunction(results, source, value, oop, data) @@ -385,13 +385,15 @@ local function checkModule(ast, word, offset, results) }, }, id = stack(function () + local md = markdown() + md:add('md', lang.script('COMPLETION_IMPORT_FROM', ('[%s](%s)'):format( + workspace.getRelativePath(uri), + uri + ))) + md:add('md', buildDesc(targetSource)) return { detail = buildDetail(targetSource), - description = lang.script('COMPLETION_IMPORT_FROM', ('[%s](%s)'):format( - workspace.getRelativePath(uri), - uri - )) - .. '\n' .. buildDesc(targetSource), + description = md, --additionalTextEdits = buildInsertRequire(ast, originUri, stemName), } end) diff --git a/script/core/hover/description.lua b/script/core/hover/description.lua index b58a08b7..afeb1bb9 100644 --- a/script/core/hover/description.lua +++ b/script/core/hover/description.lua @@ -50,7 +50,7 @@ local function asStringInRequire(source, literal) table.sort(shows) local md = markdown() md:add('md', table.concat(shows, '\n')) - return md:string() + return md end end end @@ -68,7 +68,7 @@ local function asStringView(source, literal) end local md = markdown() md:add('txt', view) - return md:string() + return md end end @@ -314,7 +314,7 @@ local function getFunctionComment(source) local md = markdown() md:add('md', comments) md:add('lua', enums) - return md:string() + return md end local function tryDocComment(source) diff --git a/script/core/hover/label.lua b/script/core/hover/label.lua index 0d2bcf6f..a29cf672 100644 --- a/script/core/hover/label.lua +++ b/script/core/hover/label.lua @@ -5,7 +5,6 @@ local buildTable = require 'core.hover.table' local infer = require 'core.infer' local vm = require 'vm' local util = require 'utility' -local searcher = require 'core.searcher' local lang = require 'language' local config = require 'config' local files = require 'files' diff --git a/script/provider/markdown.lua b/script/provider/markdown.lua index c5765571..5e564a40 100644 --- a/script/provider/markdown.lua +++ b/script/provider/markdown.lua @@ -4,6 +4,10 @@ mt.__name = 'markdown' mt._splitLine = false +function mt:__tostring() + return self:string() +end + local function checkSplitLine(self) if not self._splitLine then return diff --git a/script/provider/provider.lua b/script/provider/provider.lua index c416e748..aebf733e 100644 --- a/script/provider/provider.lua +++ b/script/provider/provider.lua @@ -445,7 +445,7 @@ proto.on('textDocument/completion', function (params) return t end)(), documentation = res.description and { - value = res.description, + value = tostring(res.description), kind = 'markdown', }, } @@ -455,7 +455,7 @@ proto.on('textDocument/completion', function (params) if resolved then item.detail = resolved.detail item.documentation = resolved.description and { - value = resolved.description, + value = tostring(resolved.description), kind = 'markdown', } end @@ -491,7 +491,7 @@ proto.on('completionItem/resolve', function (item) end item.detail = resolved.detail or item.detail item.documentation = resolved.description and { - value = resolved.description, + value = tostring(resolved.description), kind = 'markdown', } or item.documentation item.additionalTextEdits = resolved.additionalTextEdits and (function () @@ -545,7 +545,7 @@ proto.on('textDocument/signatureHelp', function (params) parameters = parameters, activeParameter = result.index - 1, documentation = result.description and { - value = result.description, + value = tostring(result.description), kind = 'markdown', }, } diff --git a/test/completion/init.lua b/test/completion/init.lua index 419bde82..3536007a 100644 --- a/test/completion/init.lua +++ b/test/completion/init.lua @@ -88,6 +88,9 @@ function TEST(script) item[k] = nil end end + if item.description then + item.description = tostring(item.description) + end end if IgnoreFunction then for i = #result, 1, -1 do diff --git a/test/crossfile/completion.lua b/test/crossfile/completion.lua index d393c8e8..e9a70199 100644 --- a/test/crossfile/completion.lua +++ b/test/crossfile/completion.lua @@ -116,7 +116,7 @@ function TEST(data) end end if item['description'] then - item['description'] = item['description'] + item['description'] = tostring(item['description']) : gsub('\r\n', '\n') end end @@ -727,6 +727,7 @@ TEST { detail = 'function', description = [[ 从 [myfunc.lua](file:///myfunc.lua) 中导入 + ```lua function (a: any, b: any) ```]], @@ -757,6 +758,7 @@ TEST { detail = 'function', description = [[ 从 [dir\myfunc.lua](file:///dir/myfunc.lua) 中导入 + ```lua function (a: any, b: any) ```]], diff --git a/test/crossfile/hover.lua b/test/crossfile/hover.lua index aaf69e7a..e673bc5f 100644 --- a/test/crossfile/hover.lua +++ b/test/crossfile/hover.lua @@ -71,6 +71,9 @@ function TEST(expect) if hover.label then hover.label = hover.label:gsub('\r\n', '\n') end + if hover.description then + hover.description = tostring(hover.description) + end assert(eq(hover.label, expect.hover.label)) assert(eq(hover.description, expect.hover.description)) end |