mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-26 07:47:54 +01:00
* Initial plan * Fix: Set HotKey to Key.Empty when HotKeySpecifier is 0xFFFF Co-authored-by: tig <585482+tig@users.noreply.github.com> * Fix code style: Use explicit type instead of var for View Co-authored-by: tig <585482+tig@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: tig <585482+tig@users.noreply.github.com>
This commit is contained in:
@@ -225,6 +225,7 @@ public partial class View // Keyboard APIs
|
||||
{
|
||||
if (HotKeySpecifier == new Rune ('\xFFFF'))
|
||||
{
|
||||
HotKey = Key.Empty;
|
||||
return; // throw new InvalidOperationException ("Can't set HotKey unless a TextFormatter has been created");
|
||||
}
|
||||
|
||||
|
||||
@@ -373,4 +373,43 @@ public class HotKeyTests
|
||||
Assert.Equal ("", view.Title);
|
||||
Assert.Equal (KeyCode.Null, view.HotKey);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void HotKeySpecifier_0xFFFF_Clears_HotKey ()
|
||||
{
|
||||
// Arrange: Create a view with a hotkey
|
||||
View view = new () { HotKeySpecifier = (Rune)'_', Title = "_Test" };
|
||||
Assert.Equal (KeyCode.T, view.HotKey);
|
||||
|
||||
// Act: Set HotKeySpecifier to 0xFFFF
|
||||
view.HotKeySpecifier = (Rune)0xFFFF;
|
||||
|
||||
// Assert: HotKey should be cleared
|
||||
Assert.Equal (KeyCode.Null, view.HotKey);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void HotKeySpecifier_0xFFFF_Before_Title_Set_Prevents_HotKey ()
|
||||
{
|
||||
// Arrange & Act: Set HotKeySpecifier to 0xFFFF before setting Title
|
||||
View view = new () { HotKeySpecifier = (Rune)0xFFFF };
|
||||
view.Title = "_Test";
|
||||
|
||||
// Assert: HotKey should remain empty
|
||||
Assert.Equal (KeyCode.Null, view.HotKey);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void HotKeySpecifier_0xFFFF_With_Underscore_In_Title ()
|
||||
{
|
||||
// Arrange & Act: This is the scenario from the bug report
|
||||
View view = new ()
|
||||
{
|
||||
HotKeySpecifier = (Rune)0xFFFF,
|
||||
Title = "my label with an _underscore"
|
||||
};
|
||||
|
||||
// Assert: HotKey should be empty (no hotkey should be set)
|
||||
Assert.Equal (KeyCode.Null, view.HotKey);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user