When using virt_text_pos = 'right_align', the placement strategy sometimes doesn't switch to 'eol' (to avoid overlaps) until it's too late.
Hypothesis
When the blame text's length exceeds the available space to the right of the buffer's text, the intention is to switch to the 'eol' extmark placement. However, there were a number of issues that could trip up the time at which it swtiches to 'eol':
if the buffer line or virtual text contain multibyte characters, they weren't counted properly in terms of screen cells that they'd consume
incorrect window identifer was passed when calculating the available space, meaning that signs/folds/numbers columns weren't properly accounted for.
Before / After
Before (using reproduction steps below)
https://github.com/lewis6991/gitsigns.nvim/assets/30904/631722f6-8e81-4a62-b627-ea2ab42bc9db
After (with fix applied)
https://github.com/lewis6991/gitsigns.nvim/assets/30904/b9307503-e14b-4a9d-a862-77b76babfdff
Reproduction steps
With the following minimal.lua:
for name, url in pairs{
gitsigns = 'https://github.com/lewis6991/gitsigns.nvim',
} do
local install_path = vim.fn.fnamemodify('gitsigns_issue/'..name, ':p')
if vim.fn.isdirectory(install_path) == 0 then
vim.fn.system { 'git', 'clone', '--depth=1', url, install_path }
end
vim.opt.runtimepath:append(install_path)
end
require('gitsigns').setup{
debug_mode = true, -- You must add this to enable debug messages
-- blame format includes multibyte '«' character:
current_line_blame_formatter = ' « <committer_time:%R>: <summary> [<abbrev_sha>]',
current_line_blame_opts = { virt_text_pos = 'right_align' },
current_line_blame = true,
}
-- Consume some extra window width:
vim.wo.number = true
vim.wo.signcolumn = 'yes'
Problem
When using
virt_text_pos = 'right_align'
, the placement strategy sometimes doesn't switch to'eol'
(to avoid overlaps) until it's too late.Hypothesis
When the blame text's length exceeds the available space to the right of the buffer's text, the intention is to switch to the 'eol' extmark placement. However, there were a number of issues that could trip up the time at which it swtiches to 'eol':
Before / After
Before (using reproduction steps below)
https://github.com/lewis6991/gitsigns.nvim/assets/30904/631722f6-8e81-4a62-b627-ea2ab42bc9dbAfter (with fix applied)
https://github.com/lewis6991/gitsigns.nvim/assets/30904/b9307503-e14b-4a9d-a862-77b76babfdffReproduction steps
With the following
minimal.lua
:Run: