summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/model/locate.rs12
-rw-r--r--tests/typ/layout/locate-group.typ19
2 files changed, 29 insertions, 2 deletions
diff --git a/src/model/locate.rs b/src/model/locate.rs
index c73c0339..05204d2e 100644
--- a/src/model/locate.rs
+++ b/src/model/locate.rs
@@ -112,7 +112,15 @@ impl EntryNode {
let index = ctx
.pins
.iter()
- .filter(|other| other.is_in(&self.group) && other.flow < pin.flow)
+ .enumerate()
+ .filter(|&(k, other)| {
+ other.is_in(&self.group)
+ && if k < idx {
+ other.flow <= pin.flow
+ } else {
+ other.flow < pin.flow
+ }
+ })
.count();
// Prepare first argument.
@@ -248,7 +256,7 @@ impl PinBoard {
/// Encode a group into a user-facing array.
fn encode_group(&self, group: &Group) -> Array {
- let mut all: Vec<_> = self.iter().filter(|other| other.is_in(group)).collect();
+ let mut all: Vec<_> = self.iter().filter(|pin| pin.is_in(group)).collect();
all.sort_by_key(|pin| pin.flow);
all.iter()
.enumerate()
diff --git a/tests/typ/layout/locate-group.typ b/tests/typ/layout/locate-group.typ
index 49d4e335..5c022f5a 100644
--- a/tests/typ/layout/locate-group.typ
+++ b/tests/typ/layout/locate-group.typ
@@ -41,3 +41,22 @@
))}
As shown in #cite("abc") and #cite("def") and #cite("abc") ...
+
+---
+// Test that `all` contains `me`.
+// Ref: false
+#show it: heading as group("headings").entry(
+ (me, all) => {
+ let last
+ for prev in all {
+ last = prev
+ if prev.index == me.index {
+ break
+ }
+ }
+ assert(last == me)
+ }
+)
+
+= A
+== B