diff options
-rw-r--r-- | script/core/completion.lua | 2 | ||||
-rw-r--r-- | script/files.lua | 40 |
2 files changed, 7 insertions, 35 deletions
diff --git a/script/core/completion.lua b/script/core/completion.lua index 653daff9..26776634 100644 --- a/script/core/completion.lua +++ b/script/core/completion.lua @@ -640,7 +640,7 @@ local function checkCommon(myUri, word, text, offset, results) if not words then goto CONTINUE end - for str in pairs(words) do + for _, str in ipairs(words) do if #results >= 100 then break end diff --git a/script/files.lua b/script/files.lua index df49b183..b84295bf 100644 --- a/script/files.lua +++ b/script/files.lua @@ -278,17 +278,13 @@ function m.getWords(uri) end local mark = {} for word in text:gmatch '([%a_][%w_]+)' do - if #word >= 3 then - if not mark[word] then - mark[word] = true - local head = word:sub(1, 2) - if not words[head] then - words[head] = {} - end - words[head][word] = true + if #word >= 3 and not mark[word] then + mark[word] = true + local head = word:sub(1, 2) + if not words[head] then + words[head] = {} end - else - words[word] = true + words[head][#words[head]+1] = word end end return words @@ -307,30 +303,6 @@ function m.getWordsOfHead(uri, head) return words[head] end ----@param uri uri ----@param word string ----@return boolean -function m.hasWord(uri, word) - uri = getUriKey(uri) - local file = m.fileMap[uri] - if not file then - return false - end - local words = m.getWords(uri) - if not words then - return false - end - if #word <= 2 then - return words[word] == true - end - local head = word:sub(1, 2) - local headWords = words[head] - if not headWords then - return false - end - return headWords[word] == true -end - --- 获取文件版本 function m.getVersion(uri) uri = getUriKey(uri) |