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

Survive /buffer clear #578

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Survive /buffer clear #578

wants to merge 2 commits into from

Conversation

oakkitten
Copy link
Collaborator

See individual commits & their messages. I hope this doesn't break things, will require a bit of hands-on testing.

When buffer is cleared using `/buffer clear` and more lines are added,
line pointers may be reused. Before, if the app was disconnected during
these events, after reconnection it was possible for the lines to appear out
of order. This happened because normally we calculate diff using pointers
only, and if we had an older line with the same pointer as the newer one,
the adapter would reuse the old view holder, which might've been displaying
the wrong line.

This fixes the issue by also looking at line contents while diffing.

This solution is not ideal:

* While we can reliably tell whether the contents of two lines are the same,
  during the diffing we also want to know whether two lines represent the
  same thing, even if the contents have changed. As the pointer can be
  reused, sometimes `areItemsTheSame` will return a false positive. However,
  with this change the negative effect of this shouldn't go beyond wrong
  animation being applied.

* Read marker may appear in a wrong place. We save the pointer to the last
  read line locally, and if the pointer is reused, there's no way for us to
  tell that the line is wrong.

Fixes #577
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants