Skip to content

Commit d459315

Browse files
committed
fix completion
`triggerCharacter` is `nil` when typing letters and numbers
1 parent 7321df7 commit d459315

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

script/core/completion/completion.lua

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1254,11 +1254,9 @@ local function tryWord(state, position, triggerCharacter, results)
12541254
checkFunctionArgByDocParam(state, word, startPos, results)
12551255
else
12561256
local afterLocal = isAfterLocal(state, startPos)
1257-
if triggerCharacter ~= nil then
1258-
local stop = checkKeyWord(state, startPos, position, word, hasSpace, afterLocal, results)
1259-
if stop then
1260-
return
1261-
end
1257+
local stop = checkKeyWord(state, startPos, position, word, hasSpace, afterLocal, results)
1258+
if stop then
1259+
return
12621260
end
12631261
if not hasSpace then
12641262
if afterLocal then

test/completion/common.lua

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3074,3 +3074,8 @@ AAA = 1
30743074
<??>
30753075
]]
30763076
(EXISTS)
3077+
3078+
TEST [[
3079+
if<??>
3080+
]]
3081+
(EXISTS)

test/completion/init.lua

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,16 @@ function TEST(script)
7373
local inputPos = catched['?'][1][2]
7474
if ContinueTyping then
7575
local triggerCharacter = script:sub(inputPos - 1, inputPos - 1)
76+
if triggerCharacter == '\n'
77+
or triggerCharacter:find '%w_' then
78+
triggerCharacter = nil
79+
end
7680
core.completion('', inputPos, triggerCharacter)
7781
end
7882
local offset = guide.positionToOffset(state, inputPos)
7983
local triggerCharacter = script:sub(offset, offset)
80-
if triggerCharacter == '\n' then
84+
if triggerCharacter == '\n'
85+
or triggerCharacter:find '%w_' then
8186
triggerCharacter = nil
8287
end
8388
local result = core.completion('', inputPos, triggerCharacter)

0 commit comments

Comments
 (0)