agitator.nvim
agitator.nvim copied to clipboard
Wrapping string breaks blame
Hello. When text is wrapped to the new line the blame of agitator is incorrect.
Expected behavior: Empty lines oposite wrapped lines or so.
https://github.com/emmanueltouzery/agitator.nvim/assets/51912173/d2c94f06-927c-4970-bfb2-03beb6966ee7
yes, i'm aware of that. I don't think it's fixable with the current approach of a split window to show the blame contents. Maybe it could be doable with some virtual text or something, but I don't see how.
I'd guess other plugins offering a similar feature (for instance fugitive) have the same flaw probably.. if they don't I could try to check exactly how they did it.
@emmanueltouzery Yeah. Fugitive works ok.
hmm I just installed fugitive to check how it does it, but it seems to me to be the same as agitator, with the same flaws. I think it resets the word-wrapping in your buffer when you enable blame... but if you set it back then i can see the problem there too. Make sure to enable word-wrapping in buffer and scroll to the end and you'll see that the end doesn't line up with fugitive as well.
Maybe agitator could disable word-wrap in your buffer when it's activated? That's probably the difference you see with fugitive, i think.
@emmanueltouzery oh I'm sorry. You are right. Fugitive doesn't work too. I cannot remember why I thought it does.
Auto disable and enabling wrapping sounds good to me. I'm just afraid about auto enabling because someone may close agitator's window manually with :q or :bd and I have no ideas how to track it to reenable wrap behavior.
But in general this solution sounds totally good.
yeah i'm not sure about re-enabling back wrapping. I'm thinking just disabling it when the blame is opened and then not touching it anymore.
@emmanueltouzery I find some implementation with z-index or so.
https://github.com/tanvirtin/vgit.nvim
Maybe it can help.
Alternatively we could open blame in the new tab.
Hello. Any updates about this issue?
I actually wrote a naive function to compute real line to screen line when there is word-wrapping. but this will break if the user later resizes the window... so i think this is just not worth doing. it'll always be possible to break it. I'll just disable wordwrap when blame is triggered. Just for future reference, the function was:
local function get_buf_line_to_win_line()
local bufnr = vim.api.nvim_win_get_buf(0)
local orig_view = vim.fn.winsaveview()
local res = {}
local line_count = vim.api.nvim_buf_line_count(bufnr)
local cur_line = 1
while cur_line <= line_count do
vim.api.nvim_win_set_cursor(0, {cur_line, 0})
res[cur_line] = vim.fn.winline()
cur_line = cur_line + 1
end
vim.fn.winrestview(orig_view)
return res
end
@emmanueltouzery Unfortunately break doesn't restore to wrap when I close blame. Totally unusable for me.
i mentioned about that earlier, in https://github.com/emmanueltouzery/agitator.nvim/issues/9#issuecomment-1546732035
probably the best is that you make your own keyboard shortcut on top of these functions here that remembers if line wrapping was set, disables it, calls this blame here, and sets back line wrapping if it was set before. you can totally do this outside of agitator.
maybe you can check what does fugitive do in this case?