Subject: [Jmap] /query anchorOffset direction

From: "Matthew Horsfall (alh)" <[email-masked]>
Date: Tue, 6 Mar 2018 09:52:48 -0500

The docs say:

anchorOffset: Number|null The index of the anchor object relative to
the index of the first result to return. This MAY be negative. For
example, -1 means the first Foo after the anchor Foo should be the
first result in the results returned (see below for more details).

This feels backwards to me.

If I have the elements 0, 1, 2, 3, 4, 5 and I say "anchor": 2,
"anchorOffset": 2, I'd expect to
go to element '2', and then add the offset to that to get to element '4'.

Positive to the right, negative to the left.

Why is this reversed in the spec? I think that may cause confusion.

-- Matthew Horsfall (alh)

---

From: Neil Jenkins <[email-masked]>
Date: Wed, 07 Mar 2018 09:08:49 +1100

On Wed, 7 Mar 2018, at 1:52 AM, Matthew Horsfall (alh) wrote:
> The index of the anchor object relative to the index of the first
> result to return.
So it's the offset of the anchor, relative to the first returned result
(i.e. it's the index in the result array that the anchor will appear
at). You think it should be the offset of the index, relative to the
anchor. If there's a consensus the latter is more intuitive, I'm happy
to flip it, but I'm not convinced that either way is necessarily more
obvious, and I think the property of "anchorOffset == index of anchor in
result array" is a nice way to be able to think about it.
Neil.

---

From: "Matthew Horsfall (alh)" <[email-masked]>
Date: Wed, 7 Mar 2018 09:20:27 -0500

On Tue, Mar 6, 2018 at 5:08 PM, Neil Jenkins <[email-masked]> wrote:
> The index of the anchor object relative to the index of the first result to
> return.
>
>
> (i.e. it's the index in the result array that the anchor will appear at).
> You think it should be the offset of the index, relative to the anchor. If
> there's a consensus the latter is more intuitive, I'm happy to flip it, but
> I'm not convinced that either way is necessarily more obvious, and I think
> the property of "anchorOffset == index of anchor in result array" is a nice
> way to be able to think about it.

Okay, after reading this explanation and rereading the spec 20 times:

I now understand why this seems flipped to me.

I'm fine with consensus as well, though I think it'd be less confusing
to go the other way I proposed, something like:

  -- The index of the anchor object relative to the index of the first
result to return.
  ++ The index of the first element to return, relative to the anchor
object. -1 means "give me the element before the anchor", 1 would mean
"give me the first element after the anchor" and so on...