diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2021-09-24 15:28:40 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2021-09-24 15:28:40 +0800 |
commit | e604de0e0871d676d2a062fc9c838b24ca0e9793 (patch) | |
tree | 5bf35ba9c038b27dd30821c8ce6b8c392c7c69c7 /script/core/command | |
parent | d3be298e8e9d1769a7444c233c1f70e316584a4d (diff) | |
download | lua-language-server-e604de0e0871d676d2a062fc9c838b24ca0e9793.zip |
resolve #659
Diffstat (limited to 'script/core/command')
-rw-r--r-- | script/core/command/autoRequire.lua | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/script/core/command/autoRequire.lua b/script/core/command/autoRequire.lua index d711fb16..b485fcb1 100644 --- a/script/core/command/autoRequire.lua +++ b/script/core/command/autoRequire.lua @@ -15,12 +15,21 @@ local function findInsertRow(uri) quot = '"', col = nil, } + local hasFounded for i = 0, #lines do local ln = lines[i] local lnText = text:match('[^\r\n]*', ln) if not lnText:find('require', 1, true) then - return i, fmt + if hasFounded then + return i, fmt + end + if not lnText:match '^local%s' + and not lnText:match '^%s*$' + and not lnText:match '^%-%-' then + return i, fmt + end else + hasFounded = true local lpPos = lnText:find '%(' if lpPos then fmt.pair = true |