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

Fix ZT crash with an Index Error. #1473

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

Conversation

theViz343
Copy link
Member

@theViz343 theViz343 commented Feb 21, 2024

What does this PR do, and why?

This PR fixes the Index Error mentioned in #1226. The PR resolves this by setting the focus pointer to the message index instead of the message ID. Other functions depending on the focus pointer also treat it as the message index, so the change in this PR keeps its usage consistent.

Outstanding aspect(s)

  • [ ]

External discussion & connections

How did you test this?

  • Manually - Behavioral changes
  • Manually - Visual changes
  • Adapting existing automated tests
  • Adding automated tests for new behavior (or missing tests)
  • Existing automated tests should already cover this (only a refactor of tested code)

Self-review checklist for each commit

  • It is a minimal coherent idea
  • It has a commit summary following the documented style (title & body)
  • It has a commit summary describing the motivation and reasoning for the change
  • It individually passes linting and tests
  • It contains test additions for any new behavior
  • It flows clearly from a previous branch commit, and/or prepares for the next commit

This commit fixes the test_get_message_false_first_anchor test.
When the first_anchor parameter is set to False in the get_messages
function, we do not assign any value to the current narrow's message
pointer. This is represented by the change in the assert statement in
the test.

Also, setting the messages_successful_response's anchor to 0 before
initializing the Model in the test leads to the pointer being set to 0,
which is not intended and is moved to after initializing the Model.
Currently, the narrow pointer is set to the anchor message id when
fetching messages from the server in the get_messages method. This
contradicts with its use in functions - get_focus_in_current_narrow and
set_focus_in_current_narrow, which treat it as an index pointing to the
last focused message in the narrow's message list. This commit makes the
pointer consistent with its current use as a message index instead of a
message id by setting it to the anchor message index in the message
list.

Fixes zulip#1226.
@zulipbot zulipbot added size: S [Automatic label added by zulipbot] bug: crash further discussion required Discuss this on #zulip-terminal on chat.zulip.org labels Feb 21, 2024
@neiljp
Copy link
Collaborator

neiljp commented Feb 22, 2024

@theViz343 Just noting here as I mentioned in the stream, that this may fix the bug, but it would be more consistent to approach this the other way around to avoid the UI index being stored in the model.

@neiljp neiljp added the PR awaiting update PR has been reviewed & is awaiting update or response to reviewer feedback label Feb 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug: crash further discussion required Discuss this on #zulip-terminal on chat.zulip.org PR awaiting update PR has been reviewed & is awaiting update or response to reviewer feedback size: S [Automatic label added by zulipbot]
Projects
None yet
Development

Successfully merging this pull request may close these issues.

IndexError on starting (focus index vs message id)
3 participants