mirror of https://github.com/icsharpcode/ILSpy.git
Browse Source
Dock recycles a single DecompilerTextView instance across every document tab via App.axaml's ControlRecyclingKey, so flipping between tabs reaches OnDataContextChanged with the FoldingManager still holding the previous tab's collapsed / expanded state. There was no capture step on the recycled-view path: only Back / Forward navigation set PendingFoldings before ApplyDocument ran. Plain tab clicks therefore landed in ApplyDocument with PendingFoldings null and every folding rebuilt at its default-open state. Track the previously bound model in a `boundModel` field. When DataContextChanged fires: - Detach the outgoing model's PropertyChanged handler (also fixes a latent multi-attach leak the old code left in place). - Snapshot the current FoldingManager's state into outgoing.LastKnownFoldings so it can be restored on a return visit. Then in ApplyDocument fall through PendingFoldings to LastKnownFoldings so the recycled-tab path lands on the same restore code Back / Forward already used. PendingFoldings still wins when both are populated -- explicit history navigation always overrides the recycled snapshot. Assisted-by: Claude:claude-opus-4-7:Claude Codepull/3755/head
1 changed files with 42 additions and 9 deletions
Loading…
Reference in new issue