Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generalize relative/absolute List positions #14

Closed
paulgb opened this issue Mar 27, 2021 · 0 comments
Closed

Generalize relative/absolute List positions #14

paulgb opened this issue Mar 27, 2021 · 0 comments

Comments

@paulgb
Copy link
Member

paulgb commented Mar 27, 2021

There are a number of ways to refer to a position in a List, which determines the behavior when the list has changed between when the reference is created and when it is used:

  • At the beginning/end of the list
  • Between two adjacent items
    • Two types of anchor behavior: anchor to the first, anchor to the second (only matters if one is moved or something is inserted between them)
    • A possible third: anchor to whichever has not been moved
  • Immediately after an item
  • Immediately before an item
  • At a specific fractional index

When adding an item in reference to another item, we usually want to fall back on a fractional index. That way, if the item it is in reference to is removed, we can fall back on the index.

For simplicity the right approach here is probably something like:

pub enum ListPosition {
    Beginning,
    End,
    AbsolutePosition(ZenoIndex),
    Before(Uuid, ZenoIndex),
    After(Uuid, ZenoIndex),
}

This would accomplish the most common use cases, but not the more complex ones.

@paulgb paulgb changed the title Generalize relative/absolute list positions Generalize relative/absolute List positions Mar 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants