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

In 6.2.3 and above PSReadLine causes 'backspace' in posh-git + Windows Terminal #1078

Closed
tig opened this issue Sep 29, 2019 · 12 comments
Closed
Labels
Resolution-External Windows-Terminal Issue that only happens in Windows Terminal

Comments

@tig
Copy link

tig commented Sep 29, 2019

Environment data

  • posh-git version/path: 1.0.0 beta3 ~\Documents\PowerShell\Modules\posh-git\1.0.0
  • PowerShell version: 6.2.3
  • git version 2.23.0.windows.1
  • OS: Microsoft Windows NT 10.0.18362.0

Steps to reproduce or exception report

Please see this posh-git Issue for more details: dahlbyk/posh-git#704

@rkeithhill

@tig tig changed the title In 6.2.3 and above PSReadLine causes 'backspace' in posh-git In 6.2.3 and above PSReadLine causes 'backspace' in posh-git + Windows Terminal Sep 30, 2019
@daxian-dbw daxian-dbw added the Windows-Terminal Issue that only happens in Windows Terminal label Sep 30, 2019
@daxian-dbw
Copy link
Member

Quoted from dahlbyk/posh-git#704 (comment)

I also noticed this, and posted about it in the Windows Terminal repository. Someone suggested it was caused by the ≡ character; at least where Cascadia Code is concerned, this is currently an "ambiguous-width" character, so the terminal's understanding of the cursor position becomes inconsistent. I think the older console that you get by launching pwsh.exe just forces everything to one character cell.

@msftrncs
Copy link
Collaborator

Then that makes this related to #1054. Character width is determined by the font … I don't know if PSReadLine has anyway it can determine this when its behind a terminal. Can the current character position be polled through a VT sequence? Spit out a character, poll the new cursor position, etc...?

@daxian-dbw
Copy link
Member

daxian-dbw commented Sep 30, 2019

Might be different. The linked issue description mentioned that it happens on Windows Terminal only:

EDIT: This does NOT happen in Hosts other than Windows Terminal. E.g. in the VSCode terminal, cmd.exe, and ConEmu it works fine.

@tig
Copy link
Author

tig commented Sep 30, 2019

Might be different. The linked issue description mentioned that it happens on Windows Terminal only:

EDIT: This does NOT happen in Hosts other than Windows Terminal. E.g. in the VSCode terminal, cmd.exe, and ConEmu it works fine.

Correct. I was unable to reproduce in any host other than Windows Terminal.

Additionally, while the character width issue may be the culprit, my instincts say this is in PSReadline as @rkeithhill and I tested a PS 6.2.3 session in Windows Terminal WITHOUT PSReadLine loaded...and the font appeared correctly without the backspace issue.

@msftrncs
Copy link
Collaborator

If the issue is in fact that sometimes (some fonts) the is a different width, then this will affect PSReadLine's ability to estimate where the cursor is. PSReadLine attempts to modify the prompt as you type, so it has to move and move again the cursor while you are typing.

@msftrncs
Copy link
Collaborator

Difference in hosts could simply be the default font, or not demonstrating the issue using the same path and same Posh Git connections.

Also, as you type, PSReadLine may modify the color of previous parts of the command line, more reason that the cursor has to be moved, and why PSReadLine needs an accurate estimate of the cursor position.

@lzybkr
Copy link
Member

lzybkr commented Sep 30, 2019

See microsoft/terminal#2928 where they are assuming ambiguous width characters are 1 character.

Note that PSReadLine hard codes the characters that are double width here.

@vexx32
Copy link

vexx32 commented Sep 30, 2019

Should emoji be / are they part of that list @lzybkr ?

@lzybkr
Copy link
Member

lzybkr commented Sep 30, 2019

Note in my link above the commented out code for surrogate pairs. Emoji have the same issue I think.

@DHowett-MSFT
Copy link

Specifically microsoft/terminal#2928 will enforce all ambiguous width chars being one cell wide -- this will fix this bug.

@tig
Copy link
Author

tig commented Oct 1, 2019

Specifically microsoft/terminal#2928 will enforce all ambiguous width chars being one cell wide -- this will fix this bug.

Woot. Thanks.

@daxian-dbw
Copy link
Member

microsoft/terminal#2928 was merged, so closing this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution-External Windows-Terminal Issue that only happens in Windows Terminal
Projects
None yet
Development

No branches or pull requests

6 participants