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

Problem with emojis/unicode (assumed double-width?) #1059

Closed
mofux opened this issue Oct 12, 2017 · 24 comments
Closed

Problem with emojis/unicode (assumed double-width?) #1059

mofux opened this issue Oct 12, 2017 · 24 comments
Assignees
Labels
duplicate type/bug Something is misbehaving

Comments

@mofux
Copy link
Contributor

mofux commented Oct 12, 2017

In current v3, Emojis seem to take up two cells. Using the arrow keys, two cells are jumped instead of one. Deleting also clears two cells.

kapture 2017-10-12 at 18 34 05

@mofux mofux added the type/bug Something is misbehaving label Oct 12, 2017
@mofux mofux added this to the 3.0.0 milestone Oct 12, 2017
@Tyriar
Copy link
Member

Tyriar commented Oct 13, 2017

I can't reproduce this on macOS/bash. I wouldn't expect it to happen unless we tried to tweak with the emoji width (make it non-1). Any more details on repro steps would be useful.

@mofux
Copy link
Contributor Author

mofux commented Oct 13, 2017

Reproduce (OSX, MacOS High Sierra)

  • start v3 demo
  • paste 😀 multiple times
  • hit left arrow key multiple times, see how it jumps two cells each time and runs into the cell boundaries.

Are you already on MacOS High Sierra, because I am? Maybe it is also related to node-pty - I can see that when inserting an emoji in Terminal.app it automatically adds a space after the emoji, and even more, I cannot select that space, it's like High Sierra would threat it as a double-width character...

Terminal.app on MacOS High Sierra
kapture 2017-10-13 at 22 55 32

@Tyriar
Copy link
Member

Tyriar commented Oct 15, 2017

This might be a high sierra thing where they tried to make Emojis better in the terminal? I can't update currently as it messes up rendering in Electron apps.

@mofux
Copy link
Contributor Author

mofux commented Oct 19, 2017

I hate to say that I've upgraded and now I'm stuck with tons of rendering glitches in all those chromium based apps 😤

@Tyriar
Copy link
Member

Tyriar commented Oct 21, 2017

Yeah I was careful to track feedback before updating as similar things happened with Sierra I think.

@Tyriar Tyriar removed this from the 3.0.0 milestone Nov 5, 2017
@Tyriar
Copy link
Member

Tyriar commented Feb 21, 2018

I notice that Terminal.app has a nice emoji experience where they're treated as proper wide characters, we can probably do it if they can 😄

@mandel59
Copy link

UAX #11 East Asian Width, Revision 31 changed emoji East Asian Wide (double-width), and wcswidth in wchar.h returns the width of strings. I guess macOS High Sierra would have supported the update.
xterm.js's wcwidth in src/CharWidth.ts doesn't have supported it yet.

@Tyriar
Copy link
Member

Tyriar commented Apr 13, 2018

@mandel59 thanks for the info!

@Tyriar
Copy link
Member

Tyriar commented Apr 13, 2018

@mandel59 I think this issue is specific to emoji, I think CJK chars should be correctly categorized as double width chars (some components may be broken though like #1387)

@tonycoco
Copy link

Reference: https://github.com/gnachman/iTerm2/blob/master/sources/NSCharacterSet+iTerm.m has some mapping solutions too.

@Tyriar
Copy link
Member

Tyriar commented Sep 22, 2018

VS Code issue: microsoft/vscode#59145

Apparently flutter run demonstrates this behavior

@DanTup
Copy link

DanTup commented Sep 24, 2018

Here's a small Dart repro for what we're seeing that doesn't require Flutter (does require Dart though):

import 'dart:async';

import 'dart:io';

// Windows console font has a limited set of Unicode characters.
final _animation = Platform.isWindows
    ? <String>[r'-', r'\', r'|', r'/']
    : <String>['🌕', '🌖', '🌗', '🌘', '🌑', '🌒', '🌓', '🌔'];
final _backspace = '\b' * _animation[0].length;

main() {
  int ticks = 0;
  void update(Timer timer) {
    if (ticks % 50 == 0) {
      stdout.write('\nDoing thing... ');
    }
    stdout.write('$_backspace${_animation[ticks++ % _animation.length]}');
  }

  new Timer.periodic(const Duration(milliseconds: 100), update);
}

Save as a .dart file and then run it with dart xxx.dart. This code here issues two backspaces for this character, which in a standard macOS terminal correctly removes the character. However, in the VS Code terminal it will backspace the emoji and then another character. If the emoji was at the start of the line this does nothing, but if it's not, the rendering slowly creeps to the left by a character (and leaves the right-half of the icon after it).

If I you remove the * _animation[0].length from the backspace so that it always does a single backspace, it works fine in the VS Code terminal, but no longer backspaces enough in the macOS Terminal (so the moons then creep to the right!).

@Tyriar Tyriar changed the title Problem with emojis (assumed double-width?) Problem with emojis/unicode (assumed double-width?) Oct 11, 2018
@Tyriar
Copy link
Member

Tyriar commented Oct 11, 2018

Also applies to Hebrew/Arabic as mentioned in microsoft/vscode#60470

@juliusecker
Copy link

juliusecker commented Feb 21, 2019

VSCode 1.31.1 on Ubuntu 18.04 experiences this issue.

When you scroll up or down your command history with the arrow keys, artifacts are picked up such that when you get to a command you want to run, chances are its illegible.

Also, after you pick up an artifact, editing the command is buggy, since what's displayed is different from what's in memory in xterm.

Steps:

Added an emoji to my prompt:
screenshot from 2019-02-21 11-10-15
Hit up arrow once to get to command npm i
screenshot from 2019-02-21 11-10-55

Notice the rogue n that was added to the prompt.

Remove the emoji from the prompt in .bashrc and reload the term and the bug goes away.

@desko27
Copy link

desko27 commented Feb 22, 2019

First things first, I wanted to thank you guys for your amazing work.

VSCode 1.31.1 on macOS Mojave 10.14.3 experiences the same. The n thing mentioned by @juliusecker happens to me too, exactly as he described.

@keyone
Copy link

keyone commented May 9, 2019

I have the same bug as mentioned by @juliusecker.
VSCode Version 1.33.1 (1.33.1) 51b0b28134d51361cf996d2f0a1c698247aeabd8 2019-04-11T08:14:39.158Z
System Version: macOS 10.14.4 (18E226)
zsh 5.7.1 (x86_64-apple-darwin17.7.0)

mrtamagotchi added a commit to mrtamagotchi/slater that referenced this issue Jun 7, 2019
Turns out VSCode has some rendering issues in their integrated terminal, where emojis eat their next neighboring character. Let's not compensate for other peoples bugs and just wait for a fix. It's in the works I've heard.

xtermjs/xterm.js#1059
@JustinGrote
Copy link

JustinGrote commented Aug 13, 2019

Very simple to reproduce in VSCode and Powershell.

emojiterminaltest.ps1

"Emoji Normal"
"😊1😊2😊3😊4"
"Emoji with Padding Spaces - What it should look like"
"😊  1😊  2😊  3😊  4"

image

Are there any resources assigned to this item? Looks like lots of regressions in other programs (Hyper, etc.) as seen on this issue thread.

@Tyriar
Copy link
Member

Tyriar commented Aug 16, 2019

@jerch is this a duplicate of #1709?

@jerch
Copy link
Member

jerch commented Aug 16, 2019

@Tyriar Yes kinda, its just an example where ppl most likely will face it - emojis 😸

@Tyriar
Copy link
Member

Tyriar commented Aug 16, 2019

I guess we'll keep them both opened as this describes the problem well and #1709 looks more at the solution, plus this one has a bunch of upvotes.

@earthengine
Copy link

It is replicatable in Windows 10, the following version:
image

image
The above is what I see in a VS code build-in terminal,
image
the above is what I see when the same text in a text file opened in VS code.

@benc-uk
Copy link

benc-uk commented Oct 6, 2019

Issue has been around nearly two years, any update?

@Tyriar
Copy link
Member

Tyriar commented Oct 7, 2019

@jerch wants to get to it soon, he has a bunch of stuff ongoing atm though. One of the big blockers for this was the new addon system which is now released.

@Tyriar
Copy link
Member

Tyriar commented Oct 7, 2019

Closing in favor of #1709 as they're essentially the same thing and we want to keep our issue count down.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate type/bug Something is misbehaving
Projects
None yet
Development

Successfully merging a pull request may close this issue.