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

TextField crashes app when pasting unicode surrogate pair #3966

Open
tznind opened this issue Mar 8, 2025 · 0 comments
Open

TextField crashes app when pasting unicode surrogate pair #3966

tznind opened this issue Mar 8, 2025 · 0 comments
Labels
Milestone

Comments

@tznind
Copy link
Collaborator

tznind commented Mar 8, 2025

Describe the bug
When pasting a 2 char pair e.g. 📄 the TextField crashes with following exception:

System.ArgumentOutOfRangeException
Specified argument was out of the range of valid values. (Parameter 'value')
   at System.Text.Rune..ctor(UInt32 value)
   at Terminal.Gui.Key.ToRune(KeyCode key) in D:\Repos\temp\gui.cs\Terminal.Gui\Input\Keyboard\Key.cs:line 349
   at Terminal.Gui.Key.get_AsRune() in D:\Repos\temp\gui.cs\Terminal.Gui\Input\Keyboard\Key.cs:line 156
   at Terminal.Gui.TextField.InsertText(Key a, Boolean usePreTextChangedCursorPos) in D:\Repos\temp\gui.cs\Terminal.Gui\Views\TextField.cs:line 1389
   at Terminal.Gui.TextField.InsertText(String toAdd, Boolean useOldCursorPos) in D:\Repos\temp\gui.cs\Terminal.Gui\Views\TextField.cs:line 750
   at Terminal.Gui.ViewsTests.TextFieldTests.TestPasteUnicodeTextField() in D:\Repos\temp\gui.cs\Tests\UnitTests\Views\TextFieldTests.cs:line 1982
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
   at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)

To Reproduce
Steps to reproduce the behavior:

    [Fact]
    public void TestPasteUnicodeTextField ()
    {
        var tf = new TextField ();
        //📄
        tf.InsertText ("\ud83d\udcc4");

    }

Expected behavior
If it is not supported by Terminal.Gui then ignore the paste i.e. paste nothing

@tznind tznind added the bug label Mar 8, 2025
@tig tig added this to the V2 Alpha milestone Mar 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: No status
Development

No branches or pull requests

2 participants