summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2023-03-09 19:22:16 +0800
committer最萌小汐 <sumneko@hotmail.com>2023-03-09 19:22:16 +0800
commit765c926aaf65229bb9ac2b7cb45b29355d71a56a (patch)
treef07ab30f32c8087446400bfdf9ae75035de2b244
parentb660030001da95338f5cff021c9aaea0be2a3fd5 (diff)
downloadlua-language-server-765c926aaf65229bb9ac2b7cb45b29355d71a56a.zip
check nil
fix #1978
-rw-r--r--changelog.md2
-rw-r--r--script/core/completion/auto-require.lua9
2 files changed, 8 insertions, 3 deletions
diff --git a/changelog.md b/changelog.md
index c8df69db..6b86db9b 100644
--- a/changelog.md
+++ b/changelog.md
@@ -9,6 +9,7 @@
* `FIX` [#1924]
* `FIX` [#1928]
* `FIX` [#1945]
+* `FIX` [#1978]
[#1715]: https://github.com/LuaLS/lua-language-server/issues/1715
[#1753]: https://github.com/LuaLS/lua-language-server/issues/1753
@@ -17,6 +18,7 @@
[#1924]: https://github.com/LuaLS/lua-language-server/issues/1924
[#1928]: https://github.com/LuaLS/lua-language-server/issues/1928
[#1945]: https://github.com/LuaLS/lua-language-server/issues/1945
+[#1978]: https://github.com/LuaLS/lua-language-server/issues/1978
## 3.6.13
`2023-3-2`
diff --git a/script/core/completion/auto-require.lua b/script/core/completion/auto-require.lua
index cec7139c..3139b911 100644
--- a/script/core/completion/auto-require.lua
+++ b/script/core/completion/auto-require.lua
@@ -56,9 +56,12 @@ function m.check(state, word, position, callback)
: gsub("(%p)", "%%%1")
: gsub("%%%?", "(.-)")
- stemName = relativePath
- : match(pattern)
- : match("[%a_][%w_]*$")
+ local stemPath = relativePath:match(pattern)
+ if not stemPath then
+ goto INNER_CONTINUE
+ end
+
+ stemName = stemPath:match("[%a_][%w_]*$")
if not stemName or testedStem[stemName] then
goto INNER_CONTINUE