Skip to content

Commit f7e7ff0

Browse files
authored
Merge pull request endoli#31 from tomcur/reading-order-epsilon
focus: make reading order `y` check use relative epsilon
2 parents 17b36a2 + 1ae4606 commit f7e7ff0

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

docs/issue_focus_direction_and_reading_order.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ In `DefaultPolicy`:
3131
1. If both entries have `order: Some(i32)`, compare by `order` (lower first).
3232
2. Otherwise fall back to **reading order** defined as:
3333
- Compare by `rect.y0` (ascending).
34-
- If `y0` is within a small epsilon, compare by `rect.x0` (ascending).
34+
- If `y0` is within a small relative epsilon, compare by `rect.x0` (ascending).
3535
- Traversal:
3636
- `Next`: move forward in this sorted list.
3737
- `Prev`: move backward in this sorted list.

understory_focus/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -383,10 +383,10 @@ fn compare_linear<K>(a: &FocusEntry<K>, b: &FocusEntry<K>) -> Ordering {
383383
}
384384

385385
fn compare_rect_reading(a: &Rect, b: &Rect) -> Ordering {
386-
const EPS: f64 = 1e-6;
386+
const RELATIVE_EPS: f64 = 1e-6;
387387
let ay = a.y0;
388388
let by = b.y0;
389-
if (ay - by).abs() > EPS {
389+
if (ay - by).abs() > f64::max(ay.abs(), by.abs()) * RELATIVE_EPS {
390390
return ay.partial_cmp(&by).unwrap_or(Ordering::Equal);
391391
}
392392
let ax = a.x0;

0 commit comments

Comments
 (0)