diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2021-09-22 16:37:54 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2021-09-22 16:37:54 +0800 |
commit | b66a9c9340d63e1a22ba7d5ccad8d9df244240d1 (patch) | |
tree | eb9e132b273e4bd093af132bffa76e046f247ba4 /test | |
parent | b7f7789e46ab8c67d25704be696a1523762b1d80 (diff) | |
download | lua-language-server-b66a9c9340d63e1a22ba7d5ccad8d9df244240d1.zip |
update
Diffstat (limited to 'test')
-rw-r--r-- | test/crossfile/hover.lua | 22 |
1 files changed, 3 insertions, 19 deletions
diff --git a/test/crossfile/hover.lua b/test/crossfile/hover.lua index a877d226..1c46214c 100644 --- a/test/crossfile/hover.lua +++ b/test/crossfile/hover.lua @@ -2,6 +2,7 @@ local files = require 'files' local furi = require 'file-uri' local core = require 'core.hover' local config = require 'config' +local catch = require 'catch' rawset(_G, 'TEST', true) @@ -36,36 +37,19 @@ local function eq(a, b) return a == b end -local function catch_target(script, sep) - local list = {} - local cur = 1 - local cut = 0 - while true do - local start, finish = script:find(('<%%%s.-%%%s>'):format(sep, sep), cur) - if not start then - break - end - list[#list+1] = { start - cut, finish - 4 - cut } - cur = finish + 1 - cut = cut + 4 - end - local new_script = script:gsub(('<%%%s(.-)%%%s>'):format(sep, sep), '%1') - return new_script, list -end - function TEST(expect) files.removeAll() local targetScript = expect[1].content local targetUri = furi.encode(expect[1].path) - local sourceScript, sourceList = catch_target(expect[2].content, '?') + local sourceScript, sourceList = catch(expect[2].content, '?') local sourceUri = furi.encode(expect[2].path) files.setText(targetUri, targetScript) files.setText(sourceUri, sourceScript) - local sourcePos = (sourceList[1][1] + sourceList[1][2]) // 2 + local sourcePos = (sourceList['?'][1][1] + sourceList['?'][1][2]) // 2 local hover = core.byUri(sourceUri, sourcePos) assert(hover) hover = tostring(hover):gsub('\r\n', '\n') |