From bae4fa96a08158668d8b005f7885a774ad1c98fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Sat, 18 Sep 2021 17:51:43 +0800 Subject: update --- script/core/completion.lua | 6 +++--- script/parser/newparser.lua | 2 +- test/completion/common.lua | 46 ++++++++++++++++++++++----------------------- 3 files changed, 27 insertions(+), 27 deletions(-) diff --git a/script/core/completion.lua b/script/core/completion.lua index 51f1087e..46847540 100644 --- a/script/core/completion.lua +++ b/script/core/completion.lua @@ -842,8 +842,8 @@ local function checkProvideLocal(state, word, start, results) end) end -local function checkFunctionArgByDocParam(state, word, start, results) - local func = guide.eachSourceContain(state.ast, start, function (source) +local function checkFunctionArgByDocParam(state, word, startPos, results) + local func = guide.eachSourceContain(state.ast, startPos, function (source) if source.type == 'function' then return source end @@ -863,7 +863,7 @@ local function checkFunctionArgByDocParam(state, word, start, results) end local firstArg = func.args and func.args[1] if not firstArg - or firstArg.start <= start and firstArg.finish >= start then + or firstArg.start <= startPos and firstArg.finish >= startPos then local firstParam = params[1] if firstParam and matchKey(word, firstParam.param[1]) then local label = {} diff --git a/script/parser/newparser.lua b/script/parser/newparser.lua index 99518261..7955a5c3 100644 --- a/script/parser/newparser.lua +++ b/script/parser/newparser.lua @@ -2131,7 +2131,6 @@ local function parseFunction(isLocal, isAction) params.finish = lastRightPosition() params.parent = func func.args = params - func.finish = params.finish end skipSpace() if Tokens[Index + 1] == ')' then @@ -2143,6 +2142,7 @@ local function parseFunction(isLocal, isAction) Index = Index + 2 skipSpace() else + func.finish = lastRightPosition() if params then params.finish = func.finish end diff --git a/test/completion/common.lua b/test/completion/common.lua index f800fa9d..d0ca92da 100644 --- a/test/completion/common.lua +++ b/test/completion/common.lua @@ -1238,9 +1238,9 @@ end label = 'a, b, c', kind = define.CompletionItemKind.Snippet, insertText = [[ -a {1:any} ----@param b {2:any} ----@param c {3:any}]] +a ${1:any} +---@param b ${2:any} +---@param c ${3:any}]] }, { label = 'a', @@ -1267,9 +1267,9 @@ function f2(a) end label = 'a, b, c', kind = define.CompletionItemKind.Snippet, insertText = [[ -a {1:any} ----@param b {2:any} ----@param c {3:any}]] +a ${1:any} +---@param b ${2:any} +---@param c ${3:any}]] }, { label = 'a', @@ -1309,9 +1309,9 @@ end label = 'a, b, c', kind = define.CompletionItemKind.Snippet, insertText = [[ -a {1:any} ----@param b {2:any} ----@param c {3:any}]] +a ${1:any} +---@param b ${2:any} +---@param c ${3:any}]] }, { label = 'a', @@ -1337,9 +1337,9 @@ end label = 'a, b, c', kind = define.CompletionItemKind.Snippet, insertText = [[ -a {1:any} ----@param b {2:any} ----@param c {3:any}]], +a ${1:any} +---@param b ${2:any} +---@param c ${3:any}]], }, { label = 'self', @@ -1864,7 +1864,7 @@ f() label = 'fun(x: number, y: number):string', kind = define.CompletionItemKind.Function, insertText = "\z -function ({1:x}, {2:y})\ +function (${1:x}, ${2:y})\ \t0\ end", }, @@ -1881,13 +1881,13 @@ end label = '@param;@return', kind = define.CompletionItemKind.Snippet, insertText = "\z -{1:comment}\ ----@param a {2:number}\ ----@param b {3:string}\ ----@param c {4:table}\ ----@return {5:number}\ ----@return {6:string}\ ----@return {7:any}", +${1:comment}\ +---@param a ${2:number}\ +---@param b ${3:string}\ +---@param c ${4:table}\ +---@return ${5:number}\ +---@return ${6:string}\ +---@return ${7:any}", }, } @@ -2376,7 +2376,7 @@ zzzz { label = 'zzzz(a)', kind = define.CompletionItemKind.Snippet, - insertText = 'zzzz({1:a: any})', + insertText = 'zzzz(${1:a: any})', }, { label = 'zzzz(a, b)', @@ -2386,7 +2386,7 @@ zzzz { label = 'zzzz(a, b)', kind = define.CompletionItemKind.Snippet, - insertText = 'zzzz({1:a: any}, {2:b: any})', + insertText = 'zzzz(${1:a: any}, ${2:b: any})', }, } Cared['insertText'] = false @@ -2470,7 +2470,7 @@ f(fun) label = 'fun(a: any, b: any):boolean', kind = define.CompletionItemKind.Function, textEdit = { - newText = 'function ({1:a}, {2:b})\n\t0\nend', + newText = 'function (${1:a}, ${2:b})\n\t0\nend', start = 68, finish = 70, } -- cgit v1.2.3