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

cursor is offset when using unicode text with combining characters #3698

Closed
kevinushey opened this issue Oct 17, 2018 · 5 comments
Closed

cursor is offset when using unicode text with combining characters #3698

kevinushey opened this issue Oct 17, 2018 · 5 comments
Labels
ace bug stale Issues which have been closed automatically due to inactivitiy.

Comments

@kevinushey
Copy link
Contributor

@kevinushey kevinushey commented Oct 17, 2018

System details

RStudio Edition : All
RStudio Version : v1.2.1061
OS Version      : macOS 10.14
R Version       : 3.5.1

Steps to reproduce the problem

Copy + paste the following text into RStudio:

åååååå

and move the cursor to the end of the line.

Describe the problem in detail

The cursor goes too far:

screen shot 2018-10-17 at 11 20 01 am

Describe the behavior you expected

The cursor should be placed at the end of the line, following the last character.

@kevinushey
Copy link
Contributor Author

@kevinushey kevinushey commented Oct 17, 2018

We could potentially handle this by using the String.prototype.normalize() function on text insertion: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize

@rcragun
Copy link

@rcragun rcragun commented Sep 20, 2019

This bug does not only apply to combining characters. It also occurs with the script/italic characters (e.g. 𝜎). But the bug does not manifest for σ.

Use case where this is important: using italic Greek characters in Shiny input labels (so that they match the characters printed by MathJax).

@traversc
Copy link

@traversc traversc commented Mar 13, 2020

The issue also affects the horizontal scroll bar and incorrectly soft-wraps text. In general, I think code point normalization isn't going to help. In the extreme case, you have zero-width characters (e.g. TAG characters e0001 - e007e) which don't have a normalization but still do offset the cursor position.

Example:

x <- "Start󠀡󠀡󠀡󠀡󠀡󠀡󠀡󠀡󠀡󠀡󠀡󠀡󠀡󠀡󠀡󠀡󠀡󠀡󠀡󠀡End" # paste me into rstudio editor
nchar(x)
[1] 28 #incorrect width
nchar(x, type = "width")
[1] 8 #correct width

@stale
Copy link

@stale stale bot commented Feb 5, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs, per https://github.com/rstudio/rstudio/wiki/Issue-Grooming. Thank you for your contributions.

@stale stale bot added the stale Issues which have been closed automatically due to inactivitiy. label Feb 5, 2021
@stale
Copy link

@stale stale bot commented Feb 19, 2021

This issue has been automatically closed due to inactivity.

@stale stale bot closed this as completed Feb 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ace bug stale Issues which have been closed automatically due to inactivitiy.
Projects
None yet
Development

No branches or pull requests

5 participants