diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2021-11-24 15:47:34 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2021-11-24 15:47:34 +0800 |
commit | 75958614871dc316759f826d0f82b26442bbc03b (patch) | |
tree | 27c24f843a23ada283cc5bd9ef3c2ff07ae1f58c /script/core | |
parent | 90d2f4190567891a2497cee80186657d416b19b0 (diff) | |
download | lua-language-server-75958614871dc316759f826d0f82b26442bbc03b.zip |
resolve #655
Diffstat (limited to 'script/core')
-rw-r--r-- | script/core/completion/completion.lua | 19 | ||||
-rw-r--r-- | script/core/completion/postfix.lua | 9 |
2 files changed, 12 insertions, 16 deletions
diff --git a/script/core/completion/completion.lua b/script/core/completion/completion.lua index a766cccc..dadc46ca 100644 --- a/script/core/completion/completion.lua +++ b/script/core/completion/completion.lua @@ -718,15 +718,6 @@ local function checkCommon(state, word, position, results) end end -local function isInString(state, position) - return guide.eachSourceContain(state.ast, position, function (source) - if source.type == 'string' - and source.start < position then - return true - end - end) -end - local function checkKeyWord(state, start, position, word, hasSpace, afterLocal, results) local text = state.lua local snipType = config.get 'Lua.completion.keywordSnippet' @@ -1204,7 +1195,7 @@ local function isFuncArg(state, position) end local function trySpecial(state, position, results) - if isInString(state, position) then + if guide.isInString(state.ast, position) then checkUri(state, position, results) checkEqualEnumInString(state, position, results) return @@ -1238,7 +1229,7 @@ local function tryWord(state, position, triggerCharacter, results) startPos = guide.offsetToPosition(state, start - 1) end local hasSpace = triggerCharacter ~= nil and finish ~= offset - if isInString(state, position) then + if guide.isInString(state.ast, position) then if not hasSpace then if #results == 0 then checkCommon(state, word, position, results) @@ -1284,7 +1275,7 @@ local function trySymbol(state, position, results) if not symbol then return nil end - if isInString(state, position) then + if guide.isInString(state.ast, position) then return nil end local startPos = guide.offsetToPosition(state, start) @@ -2045,9 +2036,7 @@ local function tryCompletions(state, position, triggerCharacter, results) tryComment(state, position, results) return end - if postfix(state, position, results) then - return - end + postfix(state, position, results) trySpecial(state, position, results) tryCallArg(state, position, results) tryTable(state, position, results) diff --git a/script/core/completion/postfix.lua b/script/core/completion/postfix.lua index a04b5e65..a47ff070 100644 --- a/script/core/completion/postfix.lua +++ b/script/core/completion/postfix.lua @@ -4,6 +4,7 @@ local matchKey = require 'core.matchkey' local subString = require 'core.substring' local define = require 'proto.define' local markdown = require 'provider.markdown' +local config = require 'config' local actions = {} @@ -148,6 +149,9 @@ local function checkPostFix(state, word, wordPosition, position, results) return source end end) + if not source then + return + end for _, action in ipairs(actions) do if matchKey(word, action.key) then action.data[1](state, source, function (newText) @@ -176,6 +180,9 @@ local function checkPostFix(state, word, wordPosition, position, results) end return function (state, position, results) + if guide.isInString(state.ast, position) then + return false + end local text = state.lua local offset = guide.positionToOffset(state, position) local word, newOffset = lookback.findWord(text, offset) @@ -183,7 +190,7 @@ return function (state, position, results) offset = newOffset - 1 end local symbol = text:sub(offset, offset) - if symbol == '@' then + if symbol == config.get 'Lua.completion.postfix' then local wordPosition = guide.offsetToPosition(state, offset - 1) checkPostFix(state, word or '', wordPosition, position, results) return true |