summaryrefslogtreecommitdiff
path: root/test/completion
diff options
context:
space:
mode:
authorsumneko <sumneko@hotmail.com>2022-02-08 21:39:52 +0800
committersumneko <sumneko@hotmail.com>2022-02-08 21:39:52 +0800
commitee476c7f4fb29ab6cf6e77205745428c0e2a8601 (patch)
treecb9d2b2b63b30cb55f030b463baee45acb42d683 /test/completion
parent01fbaf633deb9494c0b72906e71bac9f73b318ae (diff)
downloadlua-language-server-ee476c7f4fb29ab6cf6e77205745428c0e2a8601.zip
fix #937
Diffstat (limited to 'test/completion')
-rw-r--r--test/completion/common.lua7
-rw-r--r--test/completion/init.lua10
2 files changed, 15 insertions, 2 deletions
diff --git a/test/completion/common.lua b/test/completion/common.lua
index 2d887b68..bfb987c6 100644
--- a/test/completion/common.lua
+++ b/test/completion/common.lua
@@ -3067,3 +3067,10 @@ require '<??>'
(function (results)
assert(#results == 11, require 'utility'.dump(results))
end)
+
+TEST [[
+AAA = 1
+
+<??>
+]]
+(EXISTS)
diff --git a/test/completion/init.lua b/test/completion/init.lua
index 95da8890..3d0c4df6 100644
--- a/test/completion/init.lua
+++ b/test/completion/init.lua
@@ -1,6 +1,7 @@
local core = require 'core.completion'
local files = require 'files'
local catch = require 'catch'
+local guide = require 'parser.guide'
EXISTS = {'EXISTS'}
@@ -68,12 +69,17 @@ function TEST(script)
local newScript, catched = catch(script, '?')
files.setText('', newScript)
- local inputPos = catched['?'][1][1]
+ local state = files.getState('')
+ local inputPos = catched['?'][1][2]
if ContinueTyping then
local triggerCharacter = script:sub(inputPos - 1, inputPos - 1)
core.completion('', inputPos, triggerCharacter)
end
- local triggerCharacter = script:sub(inputPos, inputPos)
+ local offset = guide.positionToOffset(state, inputPos)
+ local triggerCharacter = script:sub(offset, offset)
+ if triggerCharacter == '\n' then
+ triggerCharacter = nil
+ end
local result = core.completion('', inputPos, triggerCharacter)
if not expect then