aboutsummaryrefslogtreecommitdiff
path: root/plugins/scale.lua
diff options
context:
space:
mode:
authorFrancesco Abbate <francesco.bbt@gmail.com>2021-05-31 22:10:48 +0200
committerFrancesco Abbate <francesco.bbt@gmail.com>2021-05-31 22:10:48 +0200
commit89f2b4916f81702870ee8f9c848aed96c9c304f5 (patch)
tree4bb007cebd417ef9a5703fd198a67304c54159cb /plugins/scale.lua
parent5b9a3bd28d937d131da5821f075952df80c14040 (diff)
downloadlite-xl-plugins-89f2b4916f81702870ee8f9c848aed96c9c304f5.tar.gz
lite-xl-plugins-89f2b4916f81702870ee8f9c848aed96c9c304f5.zip
Fix div by zero error in scale plugin
Simply avoid division by zero adjusting the scroll position when scrollable size is equal to the view's size. Related to issue: https://github.com/franko/lite-xl/issues/88
Diffstat (limited to 'plugins/scale.lua')
-rw-r--r--plugins/scale.lua2
1 files changed, 1 insertions, 1 deletions
diff --git a/plugins/scale.lua b/plugins/scale.lua
index 78dc9e2..b63611c 100644
--- a/plugins/scale.lua
+++ b/plugins/scale.lua
@@ -50,7 +50,7 @@ local function set_scale(scale)
local scrolls = {}
for _, view in ipairs(core.root_view.root_node:get_children()) do
local n = view:get_scrollable_size()
- if n ~= math.huge and not view:is(CommandView) then
+ if n ~= math.huge and not view:is(CommandView) and n > view.size.y then
scrolls[view] = view.scroll.y / (n - view.size.y)
end
end