diff options
Diffstat (limited to 'server/src')
-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 |