Skip to content

Commit

Permalink
feat: use 'false' for disabling max_delta check
Browse files Browse the repository at this point in the history
  • Loading branch information
declancm committed Jul 13, 2024
1 parent 2455e3f commit c72c3ae
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
18 changes: 10 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,22 +66,24 @@ return {
},
---@class ScrollOptions
options = {
-- Post-movement callback
callback = nil, ---@type function?
-- Optional post-movement callback
callback = function() end,
-- Delay between each movement step (in ms)
delay = 7,
max_delta = {
-- Maximum distance for line movements. Set to `nil` to disable
line = nil, ---@type number?
-- Maximum distance for column movements. Set to `nil` to disable
column = nil, ---@type number?
-- Maximum distance for line movements before smooth
-- scrolling is skipped. Set to `false` to disable
line = false,
-- Maximum distance for column movements before smooth
-- scrolling is skipped. Set to `false` to disable
column = false,
-- Maximum duration for a movement (in ms). Automatically adjusts the step delay
time = 1000, ---@type number
time = 1000,
},
-- The scrolling mode
-- `cursor`: Smoothly scrolls the cursor for any movement
-- `window`: Smoothly scrolls the window ONLY when the cursor moves out of view
mode = "cursor", ---@type "cursor" | "window"
mode = "cursor",
},
}
```
Expand Down
4 changes: 2 additions & 2 deletions lua/cinnamon/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ local defaults = {
callback = nil, ---@type function?
delay = 7, ---@type number
max_delta = {
line = nil, ---@type number?
column = nil, ---@type number?
line = false, ---@type number | false
column = false, ---@type number | false
time = 1000, ---@type number
},
mode = "cursor", ---@type "cursor" | "window"
Expand Down
4 changes: 2 additions & 2 deletions lua/cinnamon/scroll.lua
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ M.scroll = function(command, options)
and original_window == final_window
and vim.fn.foldclosed(final_position.line) == -1 -- Not within a closed fold
and not H.positions_within_threshold(original_position, final_position, 1, 2)
and (options.max_delta.line == nil or (line_delta <= options.max_delta.line))
and (options.max_delta.column == nil or (column_delta <= options.max_delta.column))
and (not options.max_delta.line or (line_delta <= options.max_delta.line))
and (not options.max_delta.column or (column_delta <= options.max_delta.column))
and step_delay > 0
and step_size < math.huge
)
Expand Down

0 comments on commit c72c3ae

Please sign in to comment.