Skip to content

Commit

Permalink
fix: smear between windows on same line
Browse files Browse the repository at this point in the history
Smear even if `smear_between_neighbor_lines` is true
  • Loading branch information
sphamba committed Nov 29, 2024
1 parent ce7cf75 commit 5babdd4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
17 changes: 16 additions & 1 deletion lua/smear_cursor/animation.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ local current_position = { 0, 0 }
local trailing_position = { 0, 0 }
local animating = false

-- M.current_position = setmetatable({}, {
-- __index = function(_, key)
-- return current_position[key]
-- end,
-- })

vim.defer_fn(function()
local cursor_row, cursor_col = screen.get_screen_cursor_position()
target_position = { cursor_row, cursor_col }
Expand Down Expand Up @@ -61,7 +67,6 @@ local function animate()
end

M.change_target_position = function(row, col, jump)
jump = jump or (not config.smear_between_neighbor_lines and math.abs(row - current_position[1]) <= 1)
if target_position[1] == row and target_position[2] == col then
return
end
Expand All @@ -86,4 +91,14 @@ M.change_target_position = function(row, col, jump)
end
end

setmetatable(M, {
__index = function(_, key)
if key == "current_position" then
return current_position
else
return nil
end
end,
})

return M
7 changes: 6 additions & 1 deletion lua/smear_cursor/events.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ local switching_buffer = false

local function move_cursor()
local row, col = screen.get_screen_cursor_position()
local jump = not config.smear_between_buffers and switching_buffer
local jump = (not config.smear_between_buffers and switching_buffer)
or (
not config.smear_between_neighbor_lines
and not switching_buffer
and math.abs(row - animation.current_position[1]) <= 1
)
animation.change_target_position(row, col, jump)

switching_buffer = false
Expand Down

0 comments on commit 5babdd4

Please sign in to comment.