Skip to content

Commit

Permalink
fix: use latest api in 0.10
Browse files Browse the repository at this point in the history
  • Loading branch information
ofseed authored and lewis6991 committed May 4, 2024
1 parent 9cafac3 commit bc933d2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lua/gitsigns/actions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ M.toggle_word_diff = function(value)
config.word_diff = not config.word_diff
end
-- Don't use refresh() to avoid flicker
api.nvim__buf_redraw_range(0, vim.fn.line('w0') - 1, vim.fn.line('w$'))
util.redraw({ buf = 0, range = { vim.fn.line('w0') - 1, vim.fn.line('w$') } })
return config.word_diff
end

Expand Down
2 changes: 1 addition & 1 deletion lua/gitsigns/manager.lua
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ local function apply_word_diff(bufnr, row)
end

api.nvim_buf_set_extmark(bufnr, ns, row, scol, opts)
api.nvim__buf_redraw_range(bufnr, row, row + 1)
util.redraw({ buf = bufnr, range = { row, row + 1 } })
end
end

Expand Down
9 changes: 9 additions & 0 deletions lua/gitsigns/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,15 @@ function M.get_relative_time(timestamp)
end
end

--- @param opts vim.api.keyset.redraw
function M.redraw(opts)
if vim.fn.has('nvim-0.10') == 1 then
vim.api.nvim__redraw(opts)
else
vim.api.nvim__buf_redraw(opts.buf, opts.range[1], opts.range[2])
end
end

--- @param xs string[]
--- @return boolean
local function is_dos(xs)
Expand Down

0 comments on commit bc933d2

Please sign in to comment.