Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'View.HotKey' automatic setting supports only char.IsLetterOrDigit #3038

Closed
tig opened this issue Dec 6, 2023 · 1 comment
Closed

'View.HotKey' automatic setting supports only char.IsLetterOrDigit #3038

tig opened this issue Dec 6, 2023 · 1 comment
Labels
bug v2 For discussions, issues, etc... relavant for v2

Comments

@tig
Copy link
Collaborator

tig commented Dec 6, 2023

	[Fact]
	public void Text_Change_Sets_HotKey ()
	{
		var view = new View () {
			HotKeySpecifier = new Rune ('_'),
			Text = "_Title!"
		};
		Assert.Equal (Key.T, view.HotKey);

		view.Text = "T_itle!";
		Assert.Equal (Key.I, view.HotKey);

		// BUGBUG: '!' should be supported. Line 968 of TextFormatter filters on char.IsLetterOrDigit 
		//view.Text = "Title_!";
		//Assert.Equal (Key.D1 | Key.ShiftMask, view.HotKey);
	}

I can see no reason for this limitation.

@tig tig added bug v2 For discussions, issues, etc... relavant for v2 labels Dec 6, 2023
@tig
Copy link
Collaborator Author

tig commented Dec 12, 2023

Fixed in #2927

new code in TextFormatter.FindHotKey:
image

Updated unit tests:

[Theory]
//[InlineData ("_\"k before", false, Key.Null)] // BUGBUG: Not sure why this fails
[InlineData ("\"_k before", true, Key.K)]
[InlineData ("_`~!@#$%^&*()-_=+[{]}\\|;:'\",<.>/?", true, (Key)'`')]
[InlineData ("`_~!@#$%^&*()-_=+[{]}\\|;:'\",<.>/?", true, (Key)'~')]
//[InlineData ("`~!@#$%^&*()-__=+[{]}\\|;:'\",<.>/?", true, (Key)'_')] // BUGBUG: Not sure why this fails
[InlineData ("_ ~  s  gui.cs   master ↑10", true, (Key)'')] // ~IsLetterOrDigit + Unicode
[InlineData (" ~  s  gui.cs  _ master ↑10", true, (Key)'')] // ~IsLetterOrDigit + Unicode
[InlineData ("non-english: _кдать", true, (Key)'к')] // Lower case Cryllic K (к)
public void FindHotKey_Symbols_Returns_Symbol (string text, bool found, Key expected)
{
	var hotKeySpecifier = (Rune)'_';

	var result = TextFormatter.FindHotKey (text, hotKeySpecifier, false, out int _, out Key hotKey);
	Assert.Equal (found, result);
	Assert.Equal (expected, hotKey);
}

[Theory]
[InlineData ("\"k before")]
[InlineData ("ak second")]
[InlineData ("last k")]
[InlineData ("multiple k and r")]
[InlineData ("12345")]
[InlineData ("`~!@#$%^&*()-_=+[{]}\\|;:'\",<.>/?")] // punctuation
[InlineData (" ~  s  gui.cs   master ↑10")] // ~IsLetterOrDigit + Unicode
[InlineData ("non-english: кдать")] // Lower case Cryllic K (к)
public void FindHotKey_Legacy_FirstUpperCase_NotFound_Returns_False (string text)
{
	bool supportFirstUpperCase = true;

	var hotKeySpecifier = (Rune)0;

	var result = TextFormatter.FindHotKey (text, hotKeySpecifier, supportFirstUpperCase, out int hotPos, out Key hotKey);
	Assert.False (result);
	Assert.Equal (-1, hotPos);
	Assert.Equal (Key.Null, hotKey);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug v2 For discussions, issues, etc... relavant for v2
Projects
None yet
Development

No branches or pull requests

1 participant