Skip to content

Commit

Permalink
fix: ensure fat headlines are not shifted by conflicting extmarks
Browse files Browse the repository at this point in the history
This commit makes `headlines.nvim` compatible with Nvim Orgmode's new
Virtual Indent option added by
nvim-orgmode/orgmode#627.

This also will ensure any features like it in the future from other
plugins do not interfere with the headlines later on.

In theory, extmark priorities would work here, but in pratice they do
not. If this extmark is set *last* by a higher priority using only the
virtual text, it can be arbitrarily shifted by other extmark content and
the same occurs when the extmark set is of a lower priority. By
specifying the window column to apply to, we bypass all the priorities
shenanigans and directly set the correct position of the headline.
  • Loading branch information
PriceHiller authored and lukas-reineke committed Feb 29, 2024
1 parent d39c4e6 commit 4416ee8
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lua/headlines/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ M.refresh = function()
nvim_buf_set_extmark(bufnr, M.namespace, start_row - 1, 0, {
virt_text = padding_above,
virt_text_pos = "overlay",
virt_text_win_col = 0,
hl_mode = "combine",
})
else
Expand All @@ -319,6 +320,7 @@ M.refresh = function()
nvim_buf_set_extmark(bufnr, M.namespace, start_row + 1, 0, {
virt_text = padding_below,
virt_text_pos = "overlay",
virt_text_win_col = 0,
hl_mode = "combine",
})
last_fat_headline = start_row + 1
Expand Down

0 comments on commit 4416ee8

Please sign in to comment.