diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2021-09-18 17:28:21 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2021-09-18 17:28:21 +0800 |
commit | b45a90132438bb2d84b7376066e5ff409833a13f (patch) | |
tree | b87782402cd4c5f275aa880d1c9bd82b5b5b1103 | |
parent | a7fcbe21fa6e06c46875fd8abb6d2eacb1db844e (diff) | |
download | lua-language-server-b45a90132438bb2d84b7376066e5ff409833a13f.zip |
update
-rw-r--r-- | script/core/completion.lua | 4 | ||||
-rw-r--r-- | script/parser/guide.lua | 2 | ||||
-rw-r--r-- | script/parser/newparser.lua | 41 | ||||
-rw-r--r-- | test/completion/common.lua | 2 |
4 files changed, 27 insertions, 22 deletions
diff --git a/script/core/completion.lua b/script/core/completion.lua index e37dceed..51f1087e 100644 --- a/script/core/completion.lua +++ b/script/core/completion.lua @@ -1884,14 +1884,14 @@ local function tryLuaDoc(state, text, position, results) return end if doc.type == 'doc.comment' then - local line = text:sub(doc.start, doc.range) + local line = doc.originalComment.text -- 尝试 ---$ if line == '-' then tryLuaDocOfFunction(doc, results) return end -- 尝试 ---@$ - local cate = line:match('^-%s*@(%a*)$') + local cate = line:match('^-+%s*@(%a*)$') if cate then tryLuaDocCate(cate, results) return diff --git a/script/parser/guide.lua b/script/parser/guide.lua index af623753..4a0ca21f 100644 --- a/script/parser/guide.lua +++ b/script/parser/guide.lua @@ -781,7 +781,7 @@ function m.offsetToPosition(state, offset) end break end - local start = lines[row] + local start = lines[row] - 1 if start > offset then right = row else diff --git a/script/parser/newparser.lua b/script/parser/newparser.lua index e0144dcd..99518261 100644 --- a/script/parser/newparser.lua +++ b/script/parser/newparser.lua @@ -207,21 +207,7 @@ local LocalLimit = 200 local parseExp, parseAction -local function pushError(err) - local errs = State.errs - if err.finish < err.start then - err.finish = err.start - end - local last = errs[#errs] - if last then - if last.start <= err.start and last.finish >= err.finish then - return - end - end - err.level = err.level or 'error' - errs[#errs+1] = err - return err -end +local pushError local function addSpecial(name, obj) local root = State.ast @@ -3537,7 +3523,7 @@ local function initState(lua, version, options) Chunk = {} Tokens = tokens(lua) Index = 1 - State = { + local state = { version = version, lua = lua, ast = {}, @@ -3549,11 +3535,30 @@ local function initState(lua, version, options) }, options = options or {}, } + State = state if version == 'Lua 5.1' or version == 'LuaJIT' then - State.ENVMode = '@fenv' + state.ENVMode = '@fenv' else - State.ENVMode = '_ENV' + state.ENVMode = '_ENV' end + + pushError = function (err) + local errs = state.errs + if err.finish < err.start then + err.finish = err.start + end + local last = errs[#errs] + if last then + if last.start <= err.start and last.finish >= err.finish then + return + end + end + err.level = err.level or 'error' + errs[#errs+1] = err + return err + end + + state.pushError = pushError end return function (lua, mode, version, options) diff --git a/test/completion/common.lua b/test/completion/common.lua index ff36ee0a..f800fa9d 100644 --- a/test/completion/common.lua +++ b/test/completion/common.lua @@ -1055,7 +1055,7 @@ z<??> label = 'z.b.c', kind = define.CompletionItemKind.Field, textEdit = { - start = 20001, + start = 20000, finish = 20001, newText = '_ENV["z.b.c"]', }, |