Skip to content

Fix position calculation on Windows#702

Open
ShaneEverittM wants to merge 1 commit intokkawakam:masterfrom
ShaneEverittM:fix-position-calculation
Open

Fix position calculation on Windows#702
ShaneEverittM wants to merge 1 commit intokkawakam:masterfrom
ShaneEverittM:fix-position-calculation

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