cmderdev / cmder

Lovely console emulator package for Windows
https://cmder.app
MIT License
25.81k stars 2.02k forks source link

CJK: Cursor is 1 space left to its correct position #2808

Closed niaodan2b closed 1 year ago

niaodan2b commented 1 year ago

Version Information

Cmder version: 1.3.20.151
Operating system: Win11 22H2

Cmder Edition

Cmder Mini

Description of the issue

After pressing backspace or left arrow, the cursor position is 1 space left to its correct position, as the screenshot shows. All settings are default. I've tested ConEmu, doesn't have this problem.

How to reproduce

No response

Additional context

No response

Checklist

chrisant996 commented 1 year ago

Duplicate of #2774.

This is not a Clink bug, nor a Cmder bug, nor a ConEmu bug.

CJK defines a range of characters ambiguously, and it includes the lambda λ character -- for monospace fonts they can be 1 cell width, or 2 cells wide. Depending on the combination of font, version of the OS, Active Code Page, and terminal program being used, the lambda character may display with a width different than expected, which breaks the input line display.

The simplest solution is to run chcp 65001 to make cmd.exe use UTF8.

niaodan2b commented 1 year ago

Thanks for the info ! I don't know where to run this chcp 65001, I just edited config/cmder_prompt_config.lua to change the λ for $, and problem solved.

chrisant996 commented 1 year ago

Clink v1.4.8 looks like it may have solved the width problems with the lambda character in the prompt.

Well, maybe not entirely -- the input line no longer gets garbled, but also there is no longer a space after the lambda. There's nothing Clink can do about that, though.

z-huabao commented 1 year ago

I change the startup task from {cmd:Cmder} to {bash:bash} or other shell, would not show this problem

chrisant996 commented 1 year ago

I change the startup task from {cmd:Cmder} to {bash:bash} or other shell, would not show this problem

If a shell shows a lambda (λ) in the prompt, then the shell will have some variation of this problem, unless you change the codepage to UTF-8. It is because of a mismatch in the OS when using codepage 932, 936, 949, or 950. Different shells will encounter problems after different actions, but all of them will experience the problem under some conditions.

Here are two ways you can solve the problem:

  1. Use the ConEmu Startup Environment settings page to add a line to run chcp 65001. Refer to the Startup Environment settings page documentation for more info on configuring ConEmu.
  2. You can Change the Prompt Symbol.