summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--changelog.md1
-rw-r--r--script/core/completion.lua12
2 files changed, 8 insertions, 5 deletions
diff --git a/changelog.md b/changelog.md
index 00757ca6..6b9d4833 100644
--- a/changelog.md
+++ b/changelog.md
@@ -3,6 +3,7 @@
## 1.10.0
* `NEW` workspace: supports `.dll`(`.so`) in `require`
* `CHG` supports `~` in command line
+* `CHG` completion: improve workspace words
* `FIX` [#339](https://github.com/sumneko/lua-language-server/issues/339)
## 1.9.0
diff --git a/script/core/completion.lua b/script/core/completion.lua
index e9564df3..98a30998 100644
--- a/script/core/completion.lua
+++ b/script/core/completion.lua
@@ -592,7 +592,8 @@ local function checkTableField(ast, word, start, results)
end)
end
-local function checkCommon(word, text, offset, results)
+local function checkCommon(ast, word, text, offset, results)
+ local myUri = ast.uri
local used = {}
for _, result in ipairs(results) do
used[result.label] = true
@@ -614,7 +615,8 @@ local function checkCommon(word, text, offset, results)
end
end
for _, str in ipairs(cache.commonWords) do
- if not used[str] and str ~= word then
+ if not used[str]
+ and (str ~= word or not files.eq(myUri, uri)) then
used[str] = true
if matchKey(word, str) then
results[#results+1] = {
@@ -640,8 +642,8 @@ local function checkCommon(word, text, offset, results)
end
end
else
- for str in text:gmatch '([%a_][%w_]*)' do
- if not used[str] and str ~= word then
+ for str, pos in text:gmatch '([%a_][%w_]*)()' do
+ if not used[str] and pos - 1 ~= offset then
used[str] = true
if matchKey(word, str) then
results[#results+1] = {
@@ -1184,7 +1186,7 @@ local function tryWord(ast, text, offset, results)
end
end
if not hasSpace then
- checkCommon(word, text, offset, results)
+ checkCommon(ast, word, text, offset, results)
end
end
end