diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2019-12-09 15:37:40 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2019-12-09 15:37:40 +0800 |
commit | 729073ec3619cde7c6be8102bc6e390f83d0dffd (patch) | |
tree | 7c2c2ea734e1d9421ceec99a9005f1cfdcea66f0 | |
parent | fc3dbc4a1fb36f243991bd70bf9104bc750f000f (diff) | |
download | lua-language-server-729073ec3619cde7c6be8102bc6e390f83d0dffd.zip |
过hover测试
-rw-r--r-- | script-beta/core/hover/return.lua | 2 | ||||
-rw-r--r-- | script-beta/utility.lua | 12 | ||||
-rw-r--r-- | test-beta/hover/init.lua | 19 |
3 files changed, 22 insertions, 11 deletions
diff --git a/script-beta/core/hover/return.lua b/script-beta/core/hover/return.lua index a4d3b989..e10f9416 100644 --- a/script-beta/core/hover/return.lua +++ b/script-beta/core/hover/return.lua @@ -8,7 +8,7 @@ local function asLibrary(source) local returns = {} for _, rtn in ipairs(source.returns) do local name = rtn.name - local tp = rtn.type + local tp = rtn.type or 'any' if name then returns[#returns+1] = ('%s: %s'):format(name, tp) else diff --git a/script-beta/utility.lua b/script-beta/utility.lua index c9defebc..9eaeb955 100644 --- a/script-beta/utility.lua +++ b/script-beta/utility.lua @@ -401,15 +401,23 @@ local esc = { function m.viewString(str, quo) if not quo then - if not str:find("'", 1, true) and str:find('"', 1, true) then + if str:find('[\r\n]') then + quo = '[[' + elseif not str:find("'", 1, true) and str:find('"', 1, true) then quo = "'" else quo = '"' end end if quo == "'" then + str = str:gsub('[\000-\008\011-\012\014-\031\127]', function (char) + return ('\\%03d'):format(char:byte()) + end) return quo .. str:gsub([=[['\r\n]]=], esc) .. quo elseif quo == '"' then + str = str:gsub('[\000-\008\011-\012\014-\031\127]', function (char) + return ('\\%03d'):format(char:byte()) + end) return quo .. str:gsub([=[["\r\n]]=], esc) .. quo else if str:find '\r' then @@ -418,12 +426,14 @@ function m.viewString(str, quo) local eqnum = #quo - 2 local fsymb = ']' .. ('='):rep(eqnum) .. ']' if not str:find(fsymb, 1, true) then + str = str:gsub('[\000-\008\011-\012\014-\031\127]', '') return quo .. str .. fsymb end for i = 0, 10 do local fsymb = ']' .. ('='):rep(i) .. ']' if not str:find(fsymb, 1, true) then local ssymb = '[' .. ('='):rep(i) .. '[' + str = str:gsub('[\000-\008\011-\012\014-\031\127]', '') return ssymb .. str .. fsymb end end diff --git a/test-beta/hover/init.lua b/test-beta/hover/init.lua index 1d33c6a6..c424ac51 100644 --- a/test-beta/hover/init.lua +++ b/test-beta/hover/init.lua @@ -549,17 +549,18 @@ TEST[[ <?next?>() ]] [[ -function next(table: table [, index: any]) - -> key: any, value: any +function next(table: table, index: any) + -> key: any + 2. value: any ]] -TEST[[ -local <?n?> = pairs() -]] -[[ -function n<next>(table: table [, index: any]) - -> key: any, value: any -]] +--TEST[[ +--local <?n?> = pairs() +--]] +--[[ +--function n<next>(table: table [, index: any]) +-- -> key: any, value: any +--]] TEST[[ local <?x?> = '\a' |