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 durview 16colors crash #94

Merged
merged 3 commits into from
Jan 31, 2025
Merged

Conversation

tmck-code
Copy link

@tmck-code tmck-code commented Jan 29, 2025

Context

This attempts to fix the release-blocking bug mentioned in #91

Changes

Essentially, the file_list is empty after deselecting all options. This happens somewhere in the very large method.

After some stumbling around and some feedback from cmang, I noticed that there was a commented else statement at the bottom of the loop, which seems to previously have re-populated the file_list with files and folders from the user's CWD.

https://github.com/cmang/durdraw/pull/94/files#diff-1e5995f8f73af74bc0296a94b0e316dcddab68b97c5302584a32b947dce096daR4909

  • this local file searching is done a few times within the giant loop, and it's done slightly differently, I'm unsure why but there's mostly likely a reason
  • in lieu of taking an axe to it, I instead extracted out one version of the file discovery into a separate method
    • The code that I extracted was at the beginning of the mouse input logic, as clicking with the mouse produced the correct (non-crash) result in the UI
    • Doing this did not, as it turns out, solve the issue
  • I used the same extracted method in the else block that I discovered at the bottom of the loop and it's looking 90% similar
    • the only remaining difference that I can see is that the colours are different (see below)

Demo

Screen.Recording.2025-01-30.at.7.25.58.pm.mov
first attempt
screen-20250130-084322.2.mp4

I branched this off my crash logging PR #93, but I think the order doesn't matter/you could just merge this one if you prefer 🤙

- made a decorator function to wrap around the main()
  functions/entrypoints
- log errors to file, include stacktrace
- add to durdraw, durview & durfetch
- check if the file list is empty (i.e. user has unselected every option)
- set an empty filename if that's the case, and check this to prevent
  crashes
- then let the loop proceed as usual
@cmang
Copy link
Owner

cmang commented Jan 29, 2025

Nice! Seems like a reasonable way to deal with the spaghetti. (I am open to just redoing openFilePicker() to handle navigating the directory structures in a more logical way, but haven't got my head around how quite yet.)

Still a problem: When you un-check "[X] 16colo.rs archive" with the mouse, it repopulates the interface with the list of directories and files in the local filesystem. When you un-check that with the keyboard, it doesn't, instead leaving the list blank.

@tmck-code
Copy link
Author

I am open to just redoing openFilePicker() to handle navigating the directory structures in a more logical way

I think an easy start to this would be converting the nested if statements to early continue instead, I'll have a stab at it

Still a problem: When you un-check "[X] 16colo.rs archive" with the mouse, it repopulates the interface with the list of directories and files in the local filesystem. When you un-check that with the keyboard, it doesn't, instead leaving the list blank.

Ooh legend thanks for the feedback! I'll ensure that the keyboard produces the same behaviour as the mouse 🐁

it seems like this gigantic loop resets and repopulates the list of
local files in a few different circumstances
I think that this is working nicely for mouse clicks, however for
keyboard presses this doesn't seem to happen.
I disovered a commented-out else statement near the bottom of the loop
which seemed to re-initialise the file list at some point for this
keypress case.
I've tried to reinstate the logic in a working fashion
@tmck-code
Copy link
Author

@cmang It's so close now! The only difference that I can see is that the folders/files are different colours when clicked vs using enter/spacebar, do you know how that's done?

@cmang
Copy link
Owner

cmang commented Jan 31, 2025

@cmang It's so close now! The only difference that I can see is that the folders/files are different colours when clicked vs using enter/spacebar, do you know how that's done?

Honestly... this is a bug I am willing to live with for now. Lol. This is feeling pretty solid.

I am not sure why yet. But it looks like maybe in one mode, folders[] is being populated (where they show as menuTitleColor), and in the other, it isn't.

@cmang
Copy link
Owner

cmang commented Jan 31, 2025

I'm thinking of going ahead with the merge and worrying about the colors later. I still want to add more features before the release. Maybe we can tackle the colors as a separate patch. I can work on that.

Tom, as always, I appreciate your work here!

@tmck-code
Copy link
Author

I'm thinking of going ahead with the merge and worrying about the colors later. I still want to add more features before the release. Maybe we can tackle the colors as a separate patch. I can work on that.

Tom, as always, I appreciate your work here!

You're very welcome! I'm enjoying working on this a lot. Feel free to merge if you're happy with it 🙂

Copy link
Owner

@cmang cmang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is good!

@cmang cmang merged commit 2892d5c into cmang:dev Jan 31, 2025
@tmck-code tmck-code deleted the fix-durview-16colors-crash branch February 1, 2025 01:58
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