Skip to content

Commit

Permalink
fix(virtual indent): do not return virtual indentation for headlines (n…
Browse files Browse the repository at this point in the history
…vim-orgmode#716)

This ensures when the treesitter parser has errors, the manual indent
sizing doesn't return virtual indentation for headlines.
  • Loading branch information
PriceHiller authored Apr 10, 2024
1 parent 4fbbbad commit 2ebcc60
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lua/orgmode/ui/virtual_indent.lua
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,12 @@ function VirtualIndent:_get_indent_size(line, tree_has_errors)
if tree_has_errors then
local linenr = line
while linenr > 0 do
local _, level = vim.fn.getline(linenr):find('^%*+')
-- We offset `linenr` by 1 because it's 0-indexed and `getline` is 1-indexed
local _, level = vim.fn.getline(linenr + 1):find('^%*+')
if level then
return level + 1
-- If the current line is a headline we should return no virtual indentation, otherwise
-- return virtual indentation
return (linenr == line and 0 or level + 1)
end
linenr = linenr - 1
end
Expand Down

0 comments on commit 2ebcc60

Please sign in to comment.