diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2019-11-14 11:08:12 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2019-11-14 11:08:12 +0800 |
commit | a1a5e4da0d5b1f994117d8e51ea7e105cca7d049 (patch) | |
tree | 27df0485c3e2a986d1d511b56684502fec2b5a09 /server | |
parent | 958ff43ad2a8259cab7d47ab59aeba56d3592215 (diff) | |
download | lua-language-server-a1a5e4da0d5b1f994117d8e51ea7e105cca7d049.zip |
if 只折叠 ifblock
Diffstat (limited to 'server')
-rw-r--r-- | server/src/core/folding_range.lua | 43 |
1 files changed, 23 insertions, 20 deletions
diff --git a/server/src/core/folding_range.lua b/server/src/core/folding_range.lua index 72e5b2ff..ec8029f8 100644 --- a/server/src/core/folding_range.lua +++ b/server/src/core/folding_range.lua @@ -18,33 +18,36 @@ return function (vm) if not data then return end - if data[1] == 'region' then - local start = source.start - local finish = source.finish - if data[2] == 'until' then - if #source > 0 then - finish = source[#source].finish - else - finish = start + #'repeat' - end - finish = vm.text:find('until', finish, true) or finish + local start = source.start + local finish = source.finish + if tp == 'repeat' then + if #source > 0 then + finish = source[#source].finish + else + finish = start + #'repeat' end + finish = vm.text:find('until', finish, true) or finish result[#result+1] = { start = start, finish = finish, kind = data[1], } - if tp == 'if' then - for i = 2, #source do - local block = source[i] - local nblock = source[i+1] - result[#result+1] = { - start = block.start, - finish = nblock and nblock.start or finish, - kind = data[1], - } - end + elseif tp == 'if' then + for i = 1, #source do + local block = source[i] + local nblock = source[i+1] + result[#result+1] = { + start = block.start, + finish = nblock and nblock.start or finish, + kind = data[1], + } end + elseif data[1] == 'region' then + result[#result+1] = { + start = start, + finish = finish, + kind = data[1], + } end end) if #result == 0 then |