Skip to content

Commit

Permalink
Fix calls to get graph window lines/cols
Browse files Browse the repository at this point in the history
Previously, non-graph-window lines/cols could be retrieved if the window
size was changed.
  • Loading branch information
rbong committed Aug 19, 2024
1 parent 18d4fbf commit 7f49518
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions lua/flog/highlight.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ local hl_group_names = {

function M.nvim_get_graph_hl_callback(buffer, instance_number)
local winid = vim.fn.bufwinid(buffer)
local wincol = vim.fn.wincol()

-- Read options
local enable_extended_chars = vim.g.flog_enable_extended_chars and vim.g.flog_enable_extended_chars ~= 0
Expand All @@ -29,10 +30,15 @@ function M.nvim_get_graph_hl_callback(buffer, instance_number)
local hl_cache = internal_state.hl_cache

return function (ev)
-- Update wincol
if vim.fn.win_getid() == winid then
wincol = vim.fn.wincol()
end

-- Get line/col
local start_line = vim.fn.line('w0')
local end_line = vim.fn.line('w$')
local start_col = vim.fn.virtcol('.') - vim.fn.wincol() + 2
local start_line = vim.fn.line('w0', winid)
local end_line = vim.fn.line('w$', winid)
local start_col = vim.fn.virtcol('.', false, winid) - wincol + 2
if vim.o.number or vim.o.relativenumber then
start_col = start_col + vim.o.numberwidth
end
Expand Down

0 comments on commit 7f49518

Please sign in to comment.