fix(indent): make sure cursor line is in scope for the out style. Fixes #264

This commit is contained in:
Folke Lemaitre 2024-12-12 11:55:46 +01:00
parent 19d131523a
commit 39c009fe0b
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040

View file

@ -384,9 +384,10 @@ local function step(scope, value, prev)
elseif style == "up" then
scope.animate = { from = scope.to - value, to = scope.to }
elseif style == "out" then
local line = math.min(math.max(scope.from, cursor[1]), scope.to)
scope.animate = {
from = math.max(scope.from, cursor[1] - value),
to = math.min(scope.to, cursor[1] + value),
from = math.max(scope.from, line - value),
to = math.min(scope.to, line + value),
}
else
Snacks.notify.error("Invalid animate style: " .. style, { title = "Snacks Indent", once = true })