summaryrefslogtreecommitdiff
path: root/script
diff options
context:
space:
mode:
authorqwertycxz <gmail2@qq.com>2024-07-14 08:22:24 +0800
committerqwertycxz <gmail2@qq.com>2024-07-14 08:22:24 +0800
commit74a38036bc64940520502fc8f6a28f710ce42dbb (patch)
treeae22174ea7ba477af2c8677596473d5641c063d3 /script
parentddc96bd1ec0be95a985ab82531763578bf7eb793 (diff)
downloadlua-language-server-74a38036bc64940520502fc8f6a28f710ce42dbb.zip
Fixed wholeMatch function
Diffstat (limited to 'script')
-rw-r--r--script/library.lua19
1 files changed, 6 insertions, 13 deletions
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)