Improvements to collection navigation.#21398
Open
masterpiga wants to merge 1 commit into
Open
Conversation
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.
TL;DR
The collections module previously discarded your current selection in several situations, forcing you to re-navigate the film roll/folder tree from the root. This PR makes the selection stable across two scenarios:
All changes are contained in
src/libs/collect.c.Screen.Recording.2026-06-22.at.20.42.59.mp4
Motivation
Both the film roll and folders collection rules store the full folder path as their value, and for an exact path they build the identical query (
film_id IN (SELECT id FROM film_rolls WHERE folder LIKE '<path>')). Despite this, switching the combobox between the two views cleared the entry, throwing away the selection. Likewise, after a filesystem operation that emptied (and thus removed) the selected film roll, the stored path matched nothing on rebuild, so the tree collapsed to the root and the lighttable went blank — you had to find your way back manually.The unifying principle: changing modality, or operating on files, should keep you where you were — or as close to it as still exists.
What changed
1. Film roll ⇄ folders view switch (
combo_changed)2. Selection stability across move/delete/erase (
collection_updated)A new
_fixup_stale_selection()runs before the tree is rebuilt:Supporting helpers added:
_filmroll_for_folder()— resolves a path to the best-matching film roll (exact → ancestor → descendant)._folder_exists()— checks whether a folder node still backs any film roll._folder_plain_path()— strips folders-collection suffixes (*,|%, trailing separator/%) to recover a plain path; shared by the view-switch and fixup logic.Scope
When you move all images out of the current collection, darktable already intentionally jumps the collection to the destination folder (
control_jobs.c,dt_collection_deserialize). That happens before the fixup, so this PR leaves that long-standing behavior intact rather than redirecting to the "closest to source." All other cases (delete, erase, remove-from-library, and moves where the source film roll survives) are covered.Co-authored with Claude.