From cc18cea14d1f836abcebb84a96f5029431474255 Mon Sep 17 00:00:00 2001 From: orbitalquark <70453897+orbitalquark@users.noreply.github.com> Date: Wed, 18 Sep 2024 13:53:39 -0400 Subject: Fix errors with folding in reST lexer The lexer runs without error, but still does not really work. --- lua/lexers/rest.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lua') diff --git a/lua/lexers/rest.lua b/lua/lexers/rest.lua index 9340fc2..cf739f2 100644 --- a/lua/lexers/rest.lua +++ b/lua/lexers/rest.lua @@ -173,7 +173,7 @@ local sphinx_levels = { ['#'] = 0, ['*'] = 1, ['='] = 2, ['-'] = 3, ['^'] = 4, ['"'] = 5 } -function lex:fold(text, start_pos, start_line, start_level) +function lex:fold(text, start_line, start_level) local folds, line_starts = {}, {} for pos in (text .. '\n'):gmatch('().-\r?\n') do line_starts[#line_starts + 1] = pos end local style_at, CONSTANT, level = lexer.style_at, lexer.CONSTANT, start_level @@ -185,7 +185,7 @@ function lex:fold(text, start_pos, start_line, start_level) local c = text:sub(pos, pos) local line_num = start_line + i - 1 folds[line_num] = level - if style_at[start_pos + pos - 1] == CONSTANT and c:find('^[^%w%s]') then + if style_at[pos - 1] == CONSTANT and c:find('^[^%w%s]') then local sphinx_level = FOLD_BASE + (sphinx_levels[c] or #sphinx_levels) level = not sphinx and level - 1 or sphinx_level if level < FOLD_BASE then level = FOLD_BASE end -- cgit v1.2.3