summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-07-19 21:01:18 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-07-19 21:01:18 +0800
commit8cb9c6ffac1f7c3875c02a66e9996190a39701cc (patch)
treeb2f7ca87efc0122ae8d066ce68bfe90f0552d73e
parent9b3315fe6330fb24fec3071c39118a3dd46631d7 (diff)
downloadlua-language-server-8cb9c6ffac1f7c3875c02a66e9996190a39701cc.zip
remove duplicate options
-rw-r--r--changelog.md2
-rw-r--r--script/core/command/autoRequire.lua8
2 files changed, 7 insertions, 3 deletions
diff --git a/changelog.md b/changelog.md
index 926d2b60..08a4d009 100644
--- a/changelog.md
+++ b/changelog.md
@@ -3,6 +3,8 @@
## 2.3.1
* `NEW` setting `Lua.workspace.userThirdParty`, add private user [third-parth](https://github.com/sumneko/lua-language-server/tree/master/meta/3rd) by this setting
* `CHG` path in config supports `~/xxxx`
+* `FIX` `autoRequire` inserted incorrect code
+* `FIX` `autoRequire` may provide dumplicated options
* `FIX` [#606](https://github.com/sumneko/lua-language-server/issues/606)
* `FIX` [#607](https://github.com/sumneko/lua-language-server/issues/607)
diff --git a/script/core/command/autoRequire.lua b/script/core/command/autoRequire.lua
index 68de069d..63ff784e 100644
--- a/script/core/command/autoRequire.lua
+++ b/script/core/command/autoRequire.lua
@@ -42,8 +42,10 @@ local function askAutoRequire(visiblePaths)
for _, visible in ipairs(visiblePaths) do
local expect = visible.expect
local select = lang.script(expect)
- nameMap[select] = expect
- selects[#selects+1] = select
+ if not nameMap[select] then
+ nameMap[select] = expect
+ selects[#selects+1] = select
+ end
end
local disable = lang.script.COMPLETION_DISABLE_AUTO_REQUIRE
selects[#selects+1] = disable
@@ -86,7 +88,7 @@ local function applyAutoRequire(uri, offset, name, result, fmt)
if fmt.col and fmt.col > #text then
sp = (' '):rep(fmt.col - #text - 1)
end
- text = ('local %s%s= require%s\n'):format(name, sp, quotedResult)
+ text = ('\nlocal %s%s= require%s\n'):format(name, sp, quotedResult)
client.editText(uri, {
{
start = offset,