Skip to content

Commit

Permalink
fix(windows): round row/col to 2 decimals
Browse files Browse the repository at this point in the history
Setting cmdheight to 0 and then entering a command would change the
cmdheight to 1 temporarily. This small change meant that the bounce back
was extremely slow and so never reached back to originial position.
Rounding fixes this

See #124
  • Loading branch information
rcarriga committed Sep 6, 2022
1 parent dd007d2 commit 088a28c
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions lua/notify/windows/init.lua
Expand Up @@ -261,23 +261,22 @@ function WindowAnimator:apply_updates()
self:remove_win(win)
else
local win_updated = false
local function set_field(field, round_field)
local function set_field(field, min, round_to)
if not states[field] then
return
end
local new_value = round_field and max(round(states[field].position), 1)
or states[field].position
local new_value = max(round(states[field].position, round_to), min)
if new_value == conf[field] then
return
end
win_updated = true
conf[field] = new_value
end

set_field("row", false)
set_field("col", false)
set_field("width", true)
set_field("height", true)
set_field("row", 0, 2)
set_field("col", 0, 2)
set_field("width", 1)
set_field("height", 1)

if win_updated then
api.nvim_win_set_config(win, conf)
Expand Down

0 comments on commit 088a28c

Please sign in to comment.