From bab7c96347957948d59a85ebb3e3288c8273e3bb 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, 5 Dec 2020 20:17:49 +0800 Subject: accept commit characters --- script/core/completion.lua | 1 + script/proto/define.lua | 7 ++++++- script/provider/provider.lua | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) (limited to 'script') diff --git a/script/core/completion.lua b/script/core/completion.lua index c4784322..bac4f673 100644 --- a/script/core/completion.lua +++ b/script/core/completion.lua @@ -384,6 +384,7 @@ local function checkModule(ast, word, offset, results) results[#results+1] = { label = stemName, kind = define.CompletionItemKind.Variable, + commitCharacters = {'.'}, id = stack(function () return { detail = buildDetail(targetSource), diff --git a/script/proto/define.lua b/script/proto/define.lua index 1425395a..082e382a 100644 --- a/script/proto/define.lua +++ b/script/proto/define.lua @@ -49,7 +49,7 @@ function m.position(lines, text, offset) if start < 1 then start = 1 end - if col <= finish then + if col <= finish - start + 1 then local ucol = util.utf8Len(text, start, start + col - 1) if row < 1 then row = 1 @@ -58,6 +58,11 @@ function m.position(lines, text, offset) line = row - 1, character = ucol, } + elseif col == 1 then + return { + line = row - 1, + character = 0, + } else return { line = row, diff --git a/script/provider/provider.lua b/script/provider/provider.lua index 3bd82b1c..67f07a9f 100644 --- a/script/provider/provider.lua +++ b/script/provider/provider.lua @@ -372,6 +372,7 @@ proto.on('textDocument/completion', function (params) sortText = ('%04d'):format(i), insertText = res.insertText, insertTextFormat = res.insertTextFormat, + commitCharacters = res.commitCharacters, textEdit = res.textEdit and { range = define.range( lines, -- cgit v1.2.3