Skip to content

Prevent search from wrapping infinitely - #1370

Merged
flyingmutant merged 1 commit into
cmus:masterfrom
pgaskin:workaround-tree-search-infinite-wrap
Sep 29, 2024
Merged

flyingmutant merged 1 commit into
cmus:masterfrom
pgaskin:workaround-tree-search-infinite-wrap

Conversation

@pgaskin

@pgaskin pgaskin commented Sep 22, 2024

Copy link
Copy Markdown
Member

fixes #1332

@pgaskin

pgaskin commented Sep 22, 2024

Copy link
Copy Markdown
Member Author

This workaround is hacky, but it's lightweight and non-intrusive, and it's probably good to have it even if we fix the bug properly since the search logic is complex and there's no reason why it should wrap more than once in any case.

@pgaskin
pgaskin force-pushed the workaround-tree-search-infinite-wrap branch 2 times, most recently from 9b1aa48 to 5ac406a Compare September 22, 2024 21:50
@pgaskin pgaskin changed the title Work around tree restricted search wrapping infinitely Prevent search from wrapping infinitely Sep 22, 2024
@pgaskin

pgaskin commented Sep 22, 2024

Copy link
Copy Markdown
Member Author

I've opened PR #1371 with a real fix for the bug... still probably a good idea to merge both.

@gavtroy

gavtroy commented Sep 23, 2024

Copy link
Copy Markdown
Collaborator

Looks fine. If you're confident that the other fix covers all cases you could BUG_ON instead.

IMO the comment could still be shortened considering how blunt the existing codebase tends to be.

@pgaskin

pgaskin commented Sep 23, 2024

Copy link
Copy Markdown
Member Author

BUG_ON instead

I did that in my first iteration, but I'm really not all that confident the search isn't subtly broken somewhere else (for an unrelated reason)... it took me long enough to understand the tree search enough to fix it.

I figure that if this gets hit, we shouldn't crash cmus since we don't have to, it takes a while to get bugfixes out, and if it's broken to the point of not finding something, someone will eventually open an issue and we'll see this in the logs.

IMO the comment could still be shortened considering how blunt the existing codebase tends to be.

The length of comments I write tends to scale with how absurd the code it's commenting is, and how long it took me to figure out what led to me writing it. I do think cmus needs some more comments in general.

Fair point, though. @flyingmutant?

@flyingmutant
flyingmutant force-pushed the workaround-tree-search-infinite-wrap branch from 5ac406a to 37df3fe Compare September 23, 2024 21:06
@flyingmutant

Copy link
Copy Markdown
Member

Regarding BUG_ON – not a fan of this kind of testing in production in any software.

As for the comment – I would agree in general that the codebase can be improved with tasteful sprinkling of comments (very hard to have hard rules here, it is purely question of experience/taste). However, if we are discussing this specific one – I think it can be shortened without losing anything useful.

Something like Workaround possible double-wrap bug in ..., see ... would be my take, but this is purely a matter of preference.

@pgaskin
pgaskin force-pushed the workaround-tree-search-infinite-wrap branch from 37df3fe to 3efb426 Compare September 24, 2024 03:23
@pgaskin
pgaskin force-pushed the workaround-tree-search-infinite-wrap branch from 3efb426 to 2cd57af Compare September 24, 2024 03:24
@pgaskin

pgaskin commented Sep 24, 2024

Copy link
Copy Markdown
Member Author

I edited the comment.

@flyingmutant
flyingmutant merged commit ef177ed into cmus:master Sep 29, 2024
@pgaskin
pgaskin deleted the workaround-tree-search-infinite-wrap branch September 29, 2024 19:18
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.

search, keyboard stops to respond after typing 4 slashes

3 participants