Fix project explorer tree collapsing on document save#53
Merged
Conversation
- Add TreeExpansionState: pure-Java utility (Node<T> interface + collectExpanded/restoreExpanded static methods) for saving and restoring tree expansion state without JavaFX dependency - Modify ProjectExplorerPanel.refresh() to save expanded directories and selected file before rebuilding, then restore them after - Update MarkNote.saveCurrentDocument() to call revealFile() after refresh to ensure the saved file is revealed in the tree - Add TreeExpansionStateTest with 9 unit tests covering the fix - Update build script test section to compile test sources against pre-built main classes - Add junit-platform-console-standalone-6.0.1.jar to libs/ Co-authored-by: mcgivrer <216852+mcgivrer@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix explorer tree closure on file save
Fix project explorer tree collapsing on document save
Mar 19, 2026
mcgivrer
approved these changes
Mar 19, 2026
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.
When saving a document,
ProjectExplorerPanel.refresh()rebuilt theTreeViewfrom scratch — resetting all nodes to collapsed — causing users to lose their position in the file hierarchy.Changes
TreeExpansionState(new)Node<T>interface abstracts tree nodes;isCollectable()controls which nodes participate in state capture (directories only, by default)collectExpanded(Node<T>)/restoreExpanded(Node<T>, Set<T>)snapshot and replay expansion stateProjectExplorerPanelrefresh()now snapshots expanded dirs + selected file before rebuilding the tree, then restores both afterasNode(TreeItem<File>)— private adapter bridgingTreeItem<File>toTreeExpansionState.Node<File>; applies directory-only collection filter viaisCollectable()MarkNotesaveCurrentDocument()callsrevealFile()explicitly afterrefresh()to handle "Save As" (new file not yet in saved snapshot)Tests & build
TreeExpansionStateTest— 9 unit tests: null-safety, collect/restore semantics, and the full save→refresh round-tripbuildscript updated to compile test sources against pre-built main classes (avoids recompiling JFX-dependent main sources in the test step)libs/junit-platform-console-standalone-6.0.1.jaraddedOriginal prompt
🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.