镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Using a chord to insert emoji changes all emoji on the line to "??" #3371

Open

Description

@HumanEquivalentUnit

Prerequisites

  • Write a descriptive title.
  • Make sure you are able to repro it on the latest released version
  • Search the existing issues, especially the pinned issues.

Exception report

N/A

Screenshot

PowerShell-Core-2022-07-06-15-17-03

Environment data

PS Version: 7.2.5
PS HostName: ConsoleHost (Windows Terminal)
PSReadLine Version: 2.2.6
PSReadLine EditMode: Windows
OS: 10.0.19041.1 (WinBuild.160101.0800)
BufferWidth: 120
BufferHeight: 30

Steps to reproduce

Use this code to add a chord which inserts an emoji (I have tried a few emoji, it happens for all of them):

Set-PSReadLineKeyHandler -Chord 'CTRL+y' -ScriptBlock {
    [Microsoft.PowerShell.PSConsoleReadLine]::insert('👍')
}

Then use the chord. First the emoji is inserted as ?? instead of the image, after pressing a normal letter or spacebar it turns into the image. Then using the chord again, the new emoji is inserted as ?? and all previously inserted emoji (the same emoji or different ones) change to ?? until pressing a normal letter or space returns them to being emoji.

Entering emoji through Windows' emoji keyboard (WIN+.) does not change the existing emoji in a line, and inserts them directly without entering ??. Then use the chord again, the emoji entered by Windows keyboard also turn to ??.

Expected behavior

Inserting an emoji makes it appear without needing any subsequent keypress to see them; existing emoji are unchanged while this happens.

Actual behavior

Inserting an emoji shows ?? until a subsequent keypress, and all existing emoji on the line turn to ?? until the subsequent keypress changes them back.

Activity

  1. ghost added
    Needs-Triage 🔍It's a new issue that core contributor team needs to triage.
    on Jul 6, 2022
  2. HumanEquivalentUnit commented on Jul 14, 2022

    @HumanEquivalentUnit
    Author

    Looking for a workaround, I tried ::InsertLineAbove('👍') which failed with an exception but after that, redoing the original chord makes enter characters properly - without the weird ?? behaviour seen above.

    This sequence is repeatable:

    • new terminal with wt.exe running PowerShell
    PS C:\> Set-PSReadLineKeyHandler -Chord 'Ctrl+y' -ScriptBlock { [Microsoft.PowerShell.PSConsoleReadLine]::Insert('😀') }
    PS C:\> ??    # broken, as reported above
    
    PS C:\> Set-PSReadLineKeyHandler -Chord 'Ctrl+y' -ScriptBlock { [Microsoft.PowerShell.PSConsoleReadLine]::InsertLineAbove('😀') }
    PS C:\> An exception occurred in custom key handler, see $error for more information: Cannot find an overload for "InsertLineAbove" and the argument count: "1".    # Exception when trying the chord.
    
    PS C:\> Set-PSReadLineKeyHandler -Chord 'Ctrl+y' -ScriptBlock { [Microsoft.PowerShell.PSConsoleReadLine]::Insert('😀') }
    PS C:\> 😀 now it works  # no ?? behaviour anymore
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions