Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Terminal.Gui/Views/DialogTResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,14 @@ private void SetStyle ()
{
if (IsRunning)
{
// When running, restore to Dialog scheme only if it was set to Base by SetStyle
// (i.e., the scheme was not explicitly overridden before running, e.g. by
// MessageBox.ErrorQuery which sets SchemeName = "Error" before calling app.Run).
if (SchemeName == SchemeManager.SchemesToSchemeName (Schemes.Base))
{
SchemeName = SchemeManager.SchemesToSchemeName (Schemes.Dialog);
}

Arrangement |= ViewArrangement.Movable | ViewArrangement.Resizable | ViewArrangement.Overlapped;
}
else
Expand Down
39 changes: 39 additions & 0 deletions Tests/UnitTestsParallelizable/Views/DialogTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,45 @@ public void ShadowStyle_Can_Be_Changed ()
dialog.Dispose ();
}

// Copilot
[Fact]
public void SchemeName_IsBase_WhenNotRunning ()
{
// When a Dialog is not running, it should use the Base scheme (not Dialog)
Dialog dialog = new ();

Assert.Equal (SchemeManager.SchemesToSchemeName (Schemes.Base), dialog.SchemeName);

dialog.Dispose ();
}

// Copilot
[Fact]
public void SchemeName_IsDialog_WhenRunning ()
{
using IApplication app = Application.Create ();
app.Init (DriverRegistry.Names.ANSI);

using Dialog dialog = new ();

string? schemeNameWhileRunning = null;

app.Iteration += AppOnIteration;
app.Run (dialog);
app.Iteration -= AppOnIteration;

Assert.Equal (SchemeManager.SchemesToSchemeName (Schemes.Dialog), schemeNameWhileRunning);

return;

void AppOnIteration (object? sender, EventArgs<IApplication?> e)
{
schemeNameWhileRunning = dialog.SchemeName;
app.Iteration -= AppOnIteration;
app.RequestStop ();
}
}

[Fact]
public void Text_Property ()
{
Expand Down
Loading