summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2024-07-15 14:20:19 +0800
committerGitHub <noreply@github.com>2024-07-15 14:20:19 +0800
commitf221eb304e914736f88412b97ed3e1406754a907 (patch)
tree0d7db3bfdc2c6ff5ecf6279fb5db4317de1e238b
parent491ad2f40b2e2b6285dfe88558e3d8dd0c8395bd (diff)
parentdf30d05b5e4cd127cf44c9009664894edf907b8d (diff)
downloadlua-language-server-f221eb304e914736f88412b97ed3e1406754a907.zip
Merge pull request #2756 from qwertycxz/master
Fixed wholeMatch function
-rw-r--r--changelog.md7
-rw-r--r--script/library.lua19
2 files changed, 10 insertions, 16 deletions
diff --git a/changelog.md b/changelog.md
index 67e24e88..a82efdab 100644
--- a/changelog.md
+++ b/changelog.md
@@ -4,9 +4,10 @@
<!-- Add all new changes here. They will be moved under a version at release -->
* `NEW` Add postfix snippet for `unpack`
* `FIX` `diagnostics.severity` defaulting to "Warning" when run using `--check` [#2730](https://github.com/LuaLS/lua-language-server/issues/2730)
-* `NEW` Add support for lambda style functions, `|paramList| expr` is syntactic sugar for `function(paramList) return expr end`
-* `FIX` Respect `completion.showParams` config for local function completion
+* `NEW` Add support for lambda style functions, `|paramList| expr` is syntactic sugar for `function(paramList) return expr end`
+* `FIX` Respect `completion.showParams` config for local function completion
* `CHG` Improve performance of multithreaded `--check` and `undefined-field` diagnostic
+* `FIX` Addons can now self-recommend as expected. Fixed by correcting the `wholeMatch` function
* `FIX` Now correctly evaluates the visibility of fields in a class when they are defined directly in the object. use for completion and invisible dianostic. [#2752](https://github.com/LuaLS/lua-language-server/issues/2752)
* `NEW` added lua regular expression support for Lua.doc.<scope>Name [#2753](https://github.com/LuaLS/lua-language-server/pull/2753)
* `FIX` Bad triggering of the `inject-field` diagnostic, when the fields are declared at the creation of the object [#2746](https://github.com/LuaLS/lua-language-server/issues/2746)
@@ -149,7 +150,7 @@
Cat = 1,
Dog = 2,
}
-
+
---@param animal userdata
---@param atp AnimalType
---@return boolean
diff --git a/script/library.lua b/script/library.lua
index 2e925e8d..cfc7e328 100644
--- a/script/library.lua
+++ b/script/library.lua
@@ -360,7 +360,7 @@ local function loadSingle3rdConfig(libraryDir)
if cfg.words then
for i, word in ipairs(cfg.words) do
- cfg.words[i] = '()' .. word .. '()'
+ cfg.words[i] = '([%w_]?)' .. word .. '([%w_]?)'
end
end
if cfg.files then
@@ -370,7 +370,7 @@ local function loadSingle3rdConfig(libraryDir)
else
filename = filename:gsub('\\', '/')
end
- cfg.files[i] = '()' .. filename .. '()'
+ cfg.files[i] = '([%w_]?)' .. filename .. '([%w_]?)'
end
end
@@ -515,17 +515,10 @@ end
---@param b string
---@return boolean
local function wholeMatch(a, b)
- local pos1, pos2 = a:match(b)
- if not pos1 then
- return false
- end
- local left = a:sub(pos1 - 1, pos1 - 1)
- local right = a:sub(pos2, pos2)
- if left:match '[%w_]'
- or right:match '[%w_]' then
- return false
- end
- return true
+ local captures = {
+ a:match(b),
+ }
+ return captures[1] == '' and captures[#captures] == ''
end
local function check3rdByWords(uri, configs, checkThirdParty)