Skip to content

Fix freeze when user template dir points at very large directory tree.#2644

Merged
jeremypw merged 3 commits intomainfrom
jeremypw/templates/fix-freeze
Oct 4, 2025
Merged

Fix freeze when user template dir points at very large directory tree.#2644
jeremypw merged 3 commits intomainfrom
jeremypw/templates/fix-freeze

Conversation

@jeremypw
Copy link
Contributor

Fixes #2643

The MAX_TEMPLATES constant was not being properly honored resulting in a huge menu structure being made under the circumstances of the linked issue. This is fixed and some other improvements made:

  • Honor MAX_TEMPLATES properly
  • Indicate when too many
  • Do not show empty directories
  • Insert root "Template" item when there are templates

I am uncertain about the "…too many templates" item inserted when MAX_TEMPLATES is reached and this can be removed if desired but in practice it is unlikely to appear I should think as up to 2048 templates are allowed. When the template folder contains this number or more the context menu appears with a slight but tolerable delay on modern hardware.

 * Honor MAX_TEMPLATES properly
 * Indicate when too many
 * Do not show empty directories
 * Insert root "Template" item when there are templates
@ernstki
Copy link

ernstki commented Oct 3, 2025

Can confirm this works around #2643 as detailed in this comment.

@jeremypw jeremypw requested a review from a team October 3, 2025 11:29
@jeremypw
Copy link
Contributor Author

jeremypw commented Oct 3, 2025

Thanks @ernstki - hopefully another dev will approve this for merge in due course.

Copy link
Member

@lenemter lenemter left a comment

Choose a reason for hiding this comment

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

One small nitpick. Otherwise code looks good

Insert whitespace

Co-authored-by: Leo <lenemter@gmail.com>
@jeremypw jeremypw merged commit 785a577 into main Oct 4, 2025
4 checks passed
@jeremypw jeremypw deleted the jeremypw/templates/fix-freeze branch October 4, 2025 15:36
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.

Right-clicking on the white space in the home folder freezes Files when XDG_TEMPLATES_DIR="$HOME/"

3 participants