Skip to content

Commit

Permalink
fix: always remove extmarks to prevent flickering
Browse files Browse the repository at this point in the history
  • Loading branch information
sphamba committed Dec 3, 2024
1 parent 142f838 commit da1caaf
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lua/smear_cursor/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ M.min_slope_vertical = 2

M.color_levels = 16 -- Minimum 1
M.gamma = 2.2 -- For color blending
M.max_shade_no_matrix = 0.9 -- 0: more overhangs, 1: more matrices
M.max_shade_no_matrix = 0.75 -- 0: more overhangs, 1: more matrices
M.matrix_pixel_threshold = 0.5 -- 0: all pixels, 1: no pixel
M.matrix_pixel_min_factor = 0.5 -- 0: all pixels, 1: no pixel
M.volume_reduction_exponent = 0.3 -- 0: no reduction, 1: full reduction
Expand Down
5 changes: 3 additions & 2 deletions lua/smear_cursor/draw.lua
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,10 @@ M.clear = function()
local wb = tab_windows.windows[i]

if wb and vim.api.nvim_win_is_valid(wb.window_id) then
vim.api.nvim_buf_del_extmark(wb.buffer_id, cursor_namespace, extmark_id)
if can_hide then
vim.api.nvim_win_set_config(wb.window_id, { hide = true })
else
vim.api.nvim_buf_del_extmark(wb.buffer_id, cursor_namespace, extmark_id)
vim.api.nvim_win_set_config(wb.window_id, { relative = "editor", row = 0, col = 0 })
end
end
Expand Down Expand Up @@ -401,7 +401,8 @@ M.draw_quad = function(corners, target_position)
-- Draw shifted block
if is_vertically_shifted and is_horizontally_shifted then
if vertical_shade < config.max_shade_no_matrix and horizontal_shade < config.max_shade_no_matrix then
goto continue
is_horizontally_shifted = false
is_vertically_shifted = false
elseif vertical_shade < horizontal_shade then
is_horizontally_shifted = false
else
Expand Down
12 changes: 12 additions & 0 deletions tests/test_draw_quad.lua
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,18 @@ draw.draw_quad({
{ row + 5, col + 4 },
})

-- Degenerate quads (aligned points)

row = 14
col = 23

draw.draw_quad({
{ row, col },
{ row - 1, col + 2 },
{ row + 3, col + 2 },
{ row + 3, col - 1 },
})

-- Lines

row = 23
Expand Down

0 comments on commit da1caaf

Please sign in to comment.