Skip to content
New issue

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

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

Already on GitHub? # to your account

Pasting 🤦🏼‍♂️character into repl throws exception and exits repl #270

Open
MikeSchurman opened this issue Oct 2, 2023 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@MikeSchurman
Copy link

Version

0.6.5

What happened?

I tried pasting the 🤦🏼‍♂️character into the repl and it throws an exception:

image

> Unhandled exception. System.NullReferenceException: Object reference not set to an instance of an object.──────────────┬──────────────────┐
   at PrettyPrompt.Rendering.Screen.PositionCursor(Screen screen, ConsoleCoordinate cursor)
   at PrettyPrompt.Rendering.Screen..ctor(Int32 width, Int32 height, ConsoleCoordinate cursor, ScreenArea[] screenAreas) │
   at PrettyPrompt.Renderer.<RenderOutput>g__Redraw|7_0(<>c__DisplayClass7_0&)
   at PrettyPrompt.Renderer.RenderOutput(PromptResult result, CodePane codePane, OverloadPane overloadPane, CompletionPane completionPane, IReadOnlyCollection`1 highlights, KeyPress key)│ AppContext               │
   at PrettyPrompt.Prompt.RenderSyntaxHighlightedOutput(Renderer renderer, CodePane codePane, OverloadPane overloadPane, CompletionPane completionPane, KeyPress key, String inputText, PromptResult result)─────────┘
   at PrettyPrompt.Prompt.ReadLineAsync()
   at CSharpRepl.ReadEvalPrintLoop.RunAsync(Configuration config) in D:\a\CSharpRepl\CSharpRepl\CSharpRepl\ReadEvalPrintLoop.cs:line 49
   at CSharpRepl.Program.Main(String[] args) in D:\a\CSharpRepl\CSharpRepl\CSharpRepl\Program.cs:line 68
   at CSharpRepl.Program.Main(String[] args) in D:\a\CSharpRepl\CSharpRepl\CSharpRepl\Program.cs:line 74
   at CSharpRepl.Program.<Main>(String[] args)
@MikeSchurman MikeSchurman added the bug Something isn't working label Oct 2, 2023
@waf
Copy link
Owner

waf commented Oct 3, 2023

Thanks for reporting this! It was definitely working before, and I thought we even had good integration tests around this. I'll see what happened.

@waf
Copy link
Owner

waf commented Nov 17, 2023

Just a note for myself, 🤦🏼‍♂️ is composed of the following codepoints:

Render Codepoint Name
🤦 U+1F926 FACE PALM
🏼 U+1F3FC EMOJI MODIFIER FITZPATRICK TYPE-3
U+200D ZERO WIDTH JOINER
U+2642 MALE SIGN
U+FE0F VARIATION SELECTOR-16

I'm transferring this to the PrettyPrompt underlying library repository where it should be fixed.

@waf waf transferred this issue from waf/CSharpRepl Nov 17, 2023
@tats-u
Copy link

tats-u commented Jan 20, 2024

  • ⚠️ (U+26A0 U+FE0F) → No crash
  • 🤦 (U+1F926) → No crash
  • 🤦🏼 (U+1F926 U+1F3FC) → CRASH
  • 🤦‍♂ (U+1F926 U+200D U+2642) → CRASH
  • 🤦️️ (U+1F926 U+FE0F) → No crash
  • 𠮟 (U+20B9F; means "scold") → No crash
  • 禰 (U+79B0) → No crash
  • 禰󠄀 (U+79B0 U+E0100; used in the name of the sister of the main character of Daemon Slayer: Kimetsu no Yaiba) → CRASH
  • 侮︀ (U+4FAE U+FE00) → No crash
  • 👩‍💻 (U+1F469 U+200D U+1F4BB) → No crash but not joinned

@tats-u
Copy link

tats-u commented Jan 23, 2024

Debug.Assert(previousCell.ElementWidth == 2);

This assertion fails.

public static int GetWidth(ReadOnlySpan<char> text)

This returns more than two and the returned value is set to .ElementWidth.

UnicodeWidth does not consider 🂡🂢🂣 or 🀀🀁, which are in the SMP (not BMP) and whose width should be treated as 1.

No Rune available only in .NET is used there. We can use StringInfo.GetTextElementEnumerator to split string into grapheme clusters now.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants