Skip to content

Commit

Permalink
fix(editor): use local defined div_ceil
Browse files Browse the repository at this point in the history
  • Loading branch information
kanru committed Dec 30, 2023
1 parent a1f2e75 commit 8fdf849
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -997,9 +997,20 @@ impl Selecting {
where
C: ConversionEngine<LayeredDictionary<AnyDictionary, ()>>,
{
self.candidates(editor, dict)
.len()
.div_ceil(editor.options.candidates_per_page)
// MSRV: stable after rust 1.73
fn div_ceil(lhs: usize, rhs: usize) -> usize {
let d = lhs / rhs;
let r = lhs % rhs;
if r > 0 && rhs > 0 {
d + 1
} else {
d
}
}
div_ceil(
self.candidates(editor, dict).len(),
editor.options.candidates_per_page,
)
}
fn select<C>(mut self, editor: &mut Editor<C>, n: usize) -> Transition
where
Expand Down

0 comments on commit 8fdf849

Please sign in to comment.