Skip to content

Commit 2628eda

Browse files
committed
feat: use 'false' for disabling max_delta check
1 parent 2455e3f commit 2628eda

File tree

3 files changed

+14
-12
lines changed

3 files changed

+14
-12
lines changed

README.md

+10-8
Original file line numberDiff line numberDiff line change
@@ -66,22 +66,24 @@ return {
6666
},
6767
---@class ScrollOptions
6868
options = {
69-
-- Post-movement callback
70-
callback = nil, ---@type function?
69+
-- Optional post-movement callback
70+
callback = function() end,
7171
-- Delay between each movement step (in ms)
7272
delay = 7,
7373
max_delta = {
74-
-- Maximum distance for line movements. Set to `nil` to disable
75-
line = nil, ---@type number?
76-
-- Maximum distance for column movements. Set to `nil` to disable
77-
column = nil, ---@type number?
74+
-- Maximum distance for line movements before smooth
75+
-- scrolling is skipped. Set to `false` to disable
76+
line = false,
77+
-- Maximum distance for column movements before smooth
78+
-- scrolling is skipped. Set to `false` to disable
79+
column = false,
7880
-- Maximum duration for a movement (in ms). Automatically adjusts the step delay
79-
time = 1000, ---@type number
81+
time = 1000,
8082
},
8183
-- The scrolling mode
8284
-- `cursor`: Smoothly scrolls the cursor for any movement
8385
-- `window`: Smoothly scrolls the window ONLY when the cursor moves out of view
84-
mode = "cursor", ---@type "cursor" | "window"
86+
mode = "cursor",
8587
},
8688
}
8789
```

lua/cinnamon/config.lua

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ local defaults = {
1313
callback = nil, ---@type function?
1414
delay = 7, ---@type number
1515
max_delta = {
16-
line = nil, ---@type number?
17-
column = nil, ---@type number?
16+
line = false, ---@type number | false
17+
column = false, ---@type number | false
1818
time = 1000, ---@type number
1919
},
2020
mode = "cursor", ---@type "cursor" | "window"

lua/cinnamon/scroll.lua

+2-2
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ M.scroll = function(command, options)
5656
and original_window == final_window
5757
and vim.fn.foldclosed(final_position.line) == -1 -- Not within a closed fold
5858
and not H.positions_within_threshold(original_position, final_position, 1, 2)
59-
and (options.max_delta.line == nil or (line_delta <= options.max_delta.line))
60-
and (options.max_delta.column == nil or (column_delta <= options.max_delta.column))
59+
and (not options.max_delta.line or (line_delta <= options.max_delta.line))
60+
and (not options.max_delta.column or (column_delta <= options.max_delta.column))
6161
and step_delay > 0
6262
and step_size < math.huge
6363
)

0 commit comments

Comments
 (0)