diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2024-06-11 20:52:28 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2024-06-11 20:52:28 +0800 |
commit | 3101cfb948694389cf1cc9cdbba99267f6290508 (patch) | |
tree | f3bd3325af4c64695b7d85a7150ba9c797624206 | |
parent | f437ac3594cf56cbd6ce5160a03e716f5192e85e (diff) | |
download | lua-language-server-3101cfb948694389cf1cc9cdbba99267f6290508.zip |
`FIX` Sometimes providing incorrect autocompletion when chaining calls
-rw-r--r-- | changelog.md | 3 | ||||
-rw-r--r-- | script/core/completion/completion.lua | 6 | ||||
-rw-r--r-- | test/completion/common.lua | 27 |
3 files changed, 36 insertions, 0 deletions
diff --git a/changelog.md b/changelog.md index 7891108a..fa1c2c1e 100644 --- a/changelog.md +++ b/changelog.md @@ -3,6 +3,9 @@ ## Unreleased <!-- Add all new changes here. They will be moved under a version at release --> +## 3.9.3 +* `FIX` Sometimes providing incorrect autocompletion when chaining calls + ## 3.9.2 `2024-6-6` * `NEW` Reference workspace symbols in comments using `[some text](lua://symbolName)` syntax diff --git a/script/core/completion/completion.lua b/script/core/completion/completion.lua index 242bf449..cff9c385 100644 --- a/script/core/completion/completion.lua +++ b/script/core/completion/completion.lua @@ -1594,6 +1594,12 @@ local function findCall(state, position) end end end) + if not call then + return nil + end + if call.node.finish > position then + return nil + end return call end diff --git a/test/completion/common.lua b/test/completion/common.lua index b5ffe173..fc2183d7 100644 --- a/test/completion/common.lua +++ b/test/completion/common.lua @@ -4462,3 +4462,30 @@ new 'A' { kind = define.CompletionItemKind.Property, } } + +TEST [[ +---@enum(key) enum +local t = { + a = 1, + b = 2, + c = 3, +} + +---@class A +local M + +---@param optional enum +function M:optional(optional) +end + +---@return A +function M:self() + return self +end + +---@type A +local m + +m:self(<??>):optional() +]] +(nil) |