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.

@oakkitten oakkitten requested review from mhoran and zopieux February 23, 2024 15:48
@oakkitten oakkitten force-pushed the handle-buffer-cleared branch 2 times, most recently from 728fcc6 to 8a4c9d6 Compare February 23, 2024 17:34
@oakkitten oakkitten force-pushed the handle-buffer-cleared branch from 8a4c9d6 to 83c5039 Compare December 7, 2024 14:02
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
@oakkitten oakkitten force-pushed the handle-buffer-cleared branch from 83c5039 to 18ae946 Compare December 14, 2024 15:35
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