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

Fix position calculation on Windows #702

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ShaneEverittM
Copy link

The implementations for Renderer::calculate_position differed slightly between unix and Windows. Notably, the Windows implementation did not use tty::width, but instead used UnicodeWidthStr::width. It seems that the latter did not correctly compute the length.

For context, this bug was discovered in the boa JS interpreter, where on Windows the prompt being bold and blue caused the cursor to be offset by 9 characters.

The implementations for Renderer::calculate_position differed slightly
between unix and Windows. Notably, the Windows implementation did not
use tty::width, but instead used UnicodeWidthStr::width. It seems that
the latter did not correctly compute the length.

For context, this bug was discovered in the boa JS interpreter, where on
Windows the prompt being bold and blue caused the cursor to be offset by
9 characters.
@gwenn
Copy link
Collaborator

gwenn commented May 31, 2023

See #215 (comment)

@ShaneEverittM
Copy link
Author

Dang, not sure how I missed that when looking for duplicates! Sorry!

@gwenn
Copy link
Collaborator

gwenn commented Jun 1, 2023

  1. So either we introduce some code / dependencies to remove ascii escape sequences when colours are not supported or wanted (I would prefer not to).
  2. Or you make sure that raw prompt / input contains no ascii escape sequences (and only your Highlighter adds some style).

But neither 1 or 2 are compatible with continuation prompt (see #372 (comment)).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants