summaryrefslogtreecommitdiff
path: root/script
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-10-20 15:40:50 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-10-20 15:40:50 +0800
commit6897e265fef6b0a43f5f2a6355fd0ef300b72692 (patch)
tree96cd5a99dbd87a406faaa0aaaf72644cd5f51c16 /script
parent437bae522a28cd0def7427edb0484d56e4834c7b (diff)
downloadlua-language-server-6897e265fef6b0a43f5f2a6355fd0ef300b72692.zip
fix #1642
Diffstat (limited to 'script')
-rw-r--r--script/core/completion/completion.lua11
-rw-r--r--script/core/look-backward.lua2
-rw-r--r--script/parser/guide.lua3
3 files changed, 11 insertions, 5 deletions
diff --git a/script/core/completion/completion.lua b/script/core/completion/completion.lua
index d27ff0ad..39f95ddf 100644
--- a/script/core/completion/completion.lua
+++ b/script/core/completion/completion.lua
@@ -364,7 +364,7 @@ local function checkModule(state, word, position, results)
if not locals[stemName]
and not vm.hasGlobalSets(state.uri, 'variable', stemName)
and not globals[stemName]
- and stemName:match '^[%a_][%w_]*$'
+ and stemName:match(guide.namePatternFull)
and matchKey(word, stemName) then
local targetState = files.getState(uri)
if not targetState then
@@ -422,8 +422,11 @@ local function checkModule(state, word, position, results)
end
local function checkFieldFromFieldToIndex(state, name, src, parent, word, startPos, position)
- if name:match '^[%a_][%w_]*$' then
- return nil
+ if name:match(guide.namePatternFull) then
+ if not name:match '[\x80-\xff]'
+ or config.get(state.uri, 'Lua.runtime.unicodeName') then
+ return nil
+ end
end
local textEdit, additionalTextEdits
local startOffset = guide.positionToOffset(state, startPos)
@@ -726,7 +729,7 @@ local function checkCommon(state, word, position, results)
end
end
end
- for str, offset in state.lua:gmatch '([%a_][%w_]+)()' do
+ for str, offset in state.lua:gmatch('(' .. guide.namePattern .. ')()') do
if #results >= 100 then
results.incomplete = true
break
diff --git a/script/core/look-backward.lua b/script/core/look-backward.lua
index d90c4fff..508b57eb 100644
--- a/script/core/look-backward.lua
+++ b/script/core/look-backward.lua
@@ -37,7 +37,7 @@ end
function m.findWord(text, offset)
for i = offset, 1, -1 do
- if not text:sub(i, i):match '[%w_]' then
+ if not text:sub(i, i):match '[%w_\x80-\xff]' then
if i == offset then
return nil
end
diff --git a/script/parser/guide.lua b/script/parser/guide.lua
index e8a53240..391dd3ad 100644
--- a/script/parser/guide.lua
+++ b/script/parser/guide.lua
@@ -81,6 +81,9 @@ local m = {}
m.ANY = {"<ANY>"}
+m.namePattern = '[%a_\x80-\xff][%w_\x80-\xff]*'
+m.namePatternFull = '^' .. m.namePattern .. '$'
+
local blockTypes = {
['while'] = true,
['in'] = true,