mirror of https://github.com/icsharpcode/ILSpy.git
Browse Source
ShowToolPane only activated panes still in the layout, so once the user closed the Analyzer panel (Dock removes the pane and collapses its now-empty dock) Analyze became a silent no-op -- the entity was added but the panel never reappeared. ShowToolPane now finds-or-rebuilds the pane's home ToolDock at its alignment, splicing it back into the layout where CreateLayout would have placed it, then adds and activates the pane. This same materialize-on-demand path is what lets panes be hidden by default.pull/3755/head
3 changed files with 188 additions and 32 deletions
@ -0,0 +1,78 @@ |
|||||||
|
// Copyright (c) 2026 AlphaSierraPapa for the SharpDevelop Team
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||||
|
// software and associated documentation files (the "Software"), to deal in the Software
|
||||||
|
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||||
|
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||||
|
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in all copies or
|
||||||
|
// substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
|
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||||
|
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||||
|
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||||
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
|
// DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
using System.Collections.Generic; |
||||||
|
using System.Threading.Tasks; |
||||||
|
|
||||||
|
using Avalonia.Headless.NUnit; |
||||||
|
|
||||||
|
using AwesomeAssertions; |
||||||
|
|
||||||
|
using Dock.Model.Core; |
||||||
|
|
||||||
|
using ILSpy.Analyzers; |
||||||
|
using ILSpy.AppEnv; |
||||||
|
using ILSpy.Docking; |
||||||
|
|
||||||
|
using NUnit.Framework; |
||||||
|
|
||||||
|
namespace ICSharpCode.ILSpy.Tests.Analyzers; |
||||||
|
|
||||||
|
[TestFixture] |
||||||
|
public class AnalyzerPaneVisibilityTests |
||||||
|
{ |
||||||
|
static IEnumerable<IDockable> AllDockables(IDockable? root) |
||||||
|
{ |
||||||
|
if (root is null) |
||||||
|
yield break; |
||||||
|
yield return root; |
||||||
|
if (root is IDock dock && dock.VisibleDockables is { } kids) |
||||||
|
foreach (var k in kids) |
||||||
|
foreach (var d in AllDockables(k)) |
||||||
|
yield return d; |
||||||
|
} |
||||||
|
|
||||||
|
[AvaloniaTest] |
||||||
|
public async Task Analyze_Reopens_The_Analyzer_Pane_After_The_User_Closed_It() |
||||||
|
{ |
||||||
|
// Repro for "Analyze does not make the Analyzer panel visible": the user closes the
|
||||||
|
// bottom Analyzer panel, then Analyze must bring it back. ShowToolPane only activated
|
||||||
|
// panes still in the layout, so a closed pane (removed from VisibleDockables) could
|
||||||
|
// never be restored -- Analyze became a silent no-op.
|
||||||
|
var (_, vm) = await TestHarness.BootAsync(3); |
||||||
|
var dockWorkspace = AppComposition.Current.GetExport<DockWorkspace>(); |
||||||
|
var analyzer = AppComposition.Current.GetExport<AnalyzerTreeViewModel>(); |
||||||
|
var factory = (ILSpyDockFactory)dockWorkspace.Factory; |
||||||
|
|
||||||
|
AllDockables(dockWorkspace.Layout).Should().Contain(analyzer, |
||||||
|
"baseline: the analyzer pane is in the default layout"); |
||||||
|
|
||||||
|
// The user closes the bottom Analyzer panel (its close button calls CloseDockable).
|
||||||
|
factory.CloseDockable(analyzer); |
||||||
|
AllDockables(dockWorkspace.Layout).Should().NotContain(analyzer, |
||||||
|
"closing removes the analyzer pane from the layout"); |
||||||
|
|
||||||
|
// Analyze -> ShowToolPane must restore the closed pane and activate it.
|
||||||
|
dockWorkspace.ShowToolPane(AnalyzerTreeViewModel.PaneContentId); |
||||||
|
|
||||||
|
AllDockables(dockWorkspace.Layout).Should().Contain(analyzer, |
||||||
|
"Analyze must restore the closed analyzer pane so the user sees the entity they added"); |
||||||
|
(analyzer.Owner as IDock)?.ActiveDockable.Should().BeSameAs(analyzer, |
||||||
|
"the restored pane must be the active dockable in its dock"); |
||||||
|
} |
||||||
|
} |
||||||
Loading…
Reference in new issue