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

Handle _buffer_line_data_changed #590

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

Conversation

mhoran
Copy link
Collaborator

@mhoran mhoran commented Dec 7, 2024

Adds support for _buffer_line_data_changed. Also provides the stable line ID when available and uses this when diffing.

Open question: currently this animates a line change as Animation.NewLinesFetched. Is that desirable? Should there be no animation? Some other animation? Line edits will not interrupt any running animation, but will also not trigger an animation of their own. Good enough for now?

@mhoran mhoran force-pushed the handle-buffer-line-data-changed branch 3 times, most recently from 86d8f62 to 0815d47 Compare December 7, 2024 23:20
oakkitten and others added 5 commits December 14, 2024 15:34
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
Stable line IDs have been available in hdata for some time, but were not
sent in all cases until WeeChat v4.4.0. Parse the line ID into the
pointer field for WeeChat > v4.4.0 to improve reliability of line
comparisions across the app.
@oakkitten oakkitten force-pushed the handle-buffer-line-data-changed branch from 0815d47 to 81f6833 Compare December 24, 2024 21:50
@oakkitten
Copy link
Collaborator

See git range-diff 0815d47...81f6833 for a better diff of the last push.

This removes “Don't animate edited line” and adds “Add a preference to disable handling line changes”. I like adding new preferences as much as the other guy, but there just isn't a simple way to reliably get of jankiness in animations, especially when using scripts such as url_hint that change lines just after they have been displayed. Adding a way to opt out of the new behaviour sounds like a good middle ground to me.

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.

2 participants