@@ -59,6 +59,25 @@ local function get_hash_color(sha)
5959 return hl_name
6060end
6161
62+ --- Create a right-side extmark for the blame heatmap
63+ --- @param bufnr integer
64+ --- @param lnum integer (1-indexed )
65+ --- @param win_width integer
66+ --- @param min_time integer
67+ --- @param max_time integer
68+ --- @param author_time integer
69+ local function set_right_extmark (bufnr , lnum , win_width , min_time , max_time , author_time )
70+ api .nvim_buf_set_extmark (bufnr , ns , lnum - 1 , 0 , {
71+ virt_text_win_col = win_width ,
72+ virt_text = {
73+ {
74+ ' ┃' ,
75+ get_temp_hl (min_time , max_time , author_time , 0.5 , true ),
76+ },
77+ },
78+ })
79+ end
80+
6281--- @param amount integer
6382--- @param text string
6483--- @return string
@@ -137,15 +156,7 @@ local function render(blame, win, main_win, buf_sha)
137156 hl_group = hash_hl ,
138157 })
139158
140- api .nvim_buf_set_extmark (bufnr , ns , i - 1 , 0 , {
141- virt_text_win_col = win_width ,
142- virt_text = {
143- {
144- ' ┃' ,
145- get_temp_hl (min_time , max_time , blame_info .commit .author_time , 0.5 , true ),
146- },
147- },
148- })
159+ set_right_extmark (bufnr , i , win_width , min_time , max_time , blame_info .commit .author_time )
149160
150161 if not commit_lines [i ] then
151162 api .nvim_buf_set_extmark (bufnr , ns , i - 1 , 2 , {
@@ -314,6 +325,38 @@ local function diff(bufnr, blm_win, blame)
314325 end
315326end
316327
328+ --- Update the right-side extmarks when the window is resized
329+ --- @param blm_bufnr integer
330+ --- @param blm_win integer
331+ --- @param entries table<integer,Gitsigns.BlameInfo ? >
332+ --- @param min_time integer
333+ --- @param max_time integer
334+ local function update_right_extmarks (blm_bufnr , blm_win , entries , min_time , max_time )
335+ if not api .nvim_win_is_valid (blm_win ) or not api .nvim_buf_is_valid (blm_bufnr ) then
336+ return
337+ end
338+
339+ -- Get the actual window width (not the content width)
340+ -- Subtract 1 because virt_text_win_col is 0-indexed
341+ local win_width = api .nvim_win_get_width (blm_win ) - 1
342+
343+ -- Get all extmarks and delete only those with virt_text_win_col
344+ -- These are the right-side heatmap indicators that need repositioning
345+ local extmarks = api .nvim_buf_get_extmarks (blm_bufnr , ns , 0 , - 1 , { details = true })
346+
347+ for _ , ext in ipairs (extmarks ) do
348+ local id , row , col , details = ext [1 ], ext [2 ], ext [3 ], ext [4 ]
349+ if details .virt_text_win_col then
350+ api .nvim_buf_del_extmark (blm_bufnr , ns , id )
351+ end
352+ end
353+
354+ -- Recreate the right-side extmarks with updated position
355+ for i , blame_info in ipairs (entries ) do
356+ set_right_extmark (blm_bufnr , i , win_width , min_time , max_time , blame_info .commit .author_time )
357+ end
358+ end
359+
317360--- @param mode string
318361--- @param lhs string
319362--- @param cb fun ()
@@ -481,6 +524,16 @@ function M.blame(opts)
481524 end ,
482525 })
483526
527+ -- Update right-side extmarks on window resize
528+ api .nvim_create_autocmd (' WinResized' , {
529+ buffer = blm_bufnr ,
530+ group = group ,
531+ callback = function ()
532+ local min_time , max_time = assert (cache [bufnr ]):get_blame_times ()
533+ update_right_extmarks (blm_bufnr , blm_win , blame .entries , min_time , max_time )
534+ end ,
535+ })
536+
484537 api .nvim_create_autocmd (' WinClosed' , {
485538 pattern = tostring (blm_win ),
486539 group = group ,
0 commit comments