Skip to content

Commit f221eb3

Browse files
authored
Merge pull request #2756 from qwertycxz/master
Fixed wholeMatch function
2 parents 491ad2f + df30d05 commit f221eb3

File tree

2 files changed

+10
-16
lines changed

2 files changed

+10
-16
lines changed

changelog.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
<!-- Add all new changes here. They will be moved under a version at release -->
55
* `NEW` Add postfix snippet for `unpack`
66
* `FIX` `diagnostics.severity` defaulting to "Warning" when run using `--check` [#2730](https://github.com/LuaLS/lua-language-server/issues/2730)
7-
* `NEW` Add support for lambda style functions, `|paramList| expr` is syntactic sugar for `function(paramList) return expr end`
8-
* `FIX` Respect `completion.showParams` config for local function completion
7+
* `NEW` Add support for lambda style functions, `|paramList| expr` is syntactic sugar for `function(paramList) return expr end`
8+
* `FIX` Respect `completion.showParams` config for local function completion
99
* `CHG` Improve performance of multithreaded `--check` and `undefined-field` diagnostic
10+
* `FIX` Addons can now self-recommend as expected. Fixed by correcting the `wholeMatch` function
1011
* `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)
1112
* `NEW` added lua regular expression support for Lua.doc.<scope>Name [#2753](https://github.com/LuaLS/lua-language-server/pull/2753)
1213
* `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 @@
149150
Cat = 1,
150151
Dog = 2,
151152
}
152-
153+
153154
---@param animal userdata
154155
---@param atp AnimalType
155156
---@return boolean

script/library.lua

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ local function loadSingle3rdConfig(libraryDir)
360360

361361
if cfg.words then
362362
for i, word in ipairs(cfg.words) do
363-
cfg.words[i] = '()' .. word .. '()'
363+
cfg.words[i] = '([%w_]?)' .. word .. '([%w_]?)'
364364
end
365365
end
366366
if cfg.files then
@@ -370,7 +370,7 @@ local function loadSingle3rdConfig(libraryDir)
370370
else
371371
filename = filename:gsub('\\', '/')
372372
end
373-
cfg.files[i] = '()' .. filename .. '()'
373+
cfg.files[i] = '([%w_]?)' .. filename .. '([%w_]?)'
374374
end
375375
end
376376

@@ -515,17 +515,10 @@ end
515515
---@param b string
516516
---@return boolean
517517
local function wholeMatch(a, b)
518-
local pos1, pos2 = a:match(b)
519-
if not pos1 then
520-
return false
521-
end
522-
local left = a:sub(pos1 - 1, pos1 - 1)
523-
local right = a:sub(pos2, pos2)
524-
if left:match '[%w_]'
525-
or right:match '[%w_]' then
526-
return false
527-
end
528-
return true
518+
local captures = {
519+
a:match(b),
520+
}
521+
return captures[1] == '' and captures[#captures] == ''
529522
end
530523

531524
local function check3rdByWords(uri, configs, checkThirdParty)

0 commit comments

Comments
 (0)