Repository navigation
search, namedqueries: move first/last in an empty buffer - #1867
Merged
Merged
Conversation
"move first" and "move last" raised IndexError ("Can't set focus,
ListBox is empty") in a search without results or with a malformed
query, and "move first" in the named queries buffer without any named
queries. Do nothing there instead, as the named queries buffer already
does for "move last".
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TR9KjabaVCyHnpqp2kQZHC
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
move firstandmove lastshowed an error ("Can't set focus, ListBox is empty") instead of doing nothing in:move lastalso failed with'NoneType' object has no attribute 'empty');move firstonly;move lastalready checked).The search buffer now returns early when its list has no focus widget, which urwid documents as
Nonefor an emptyListBoxsince before 2.2.0. The named queries buffer checksself.queries, as itsrebuilddoes. The bug was found in the review of #1865.Testing
Unit tests in
tests/buffers/test_search.py(no results, malformed query) andtests/buffers/test_namedqueries.py(no queries) run the real urwidListBox; all three fail without the fix. The full suite passes. During development, equivalent end-to-end tests in a pty also failed without the fix and passed with it; they were replaced by the unit tests on review-design's advice.NEWS: info: "move first" and "move last" no longer fail in an empty search or named queries buffer
Review findings and resolution
review-correctness
move firstuntil refreshed: left, a rare corner where doing nothing is reasonable.TagListBufferhas the same unguardedfocus_first, but an empty tag list cannot be opened, becauserebuilddivides by the number of tags: left, as a notmuch database in use always has tags.HOME=/nonexistenton the reviewer's machine: an environment effect (a system urwidtrees 1.0.4 is picked up), same on main.review-design
TagListBuffer.rebuildraisesZeroDivisionErrorwithout tags: left, as a notmuch database in use always has tags.🤖 Generated with Claude Code
https://claude.ai/code/session_01TR9KjabaVCyHnpqp2kQZHC