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

TeXstudio double counts Unicode characters leading to wrong alignment #2427

Open
randolf-scholz opened this issue Jun 21, 2022 · 1 comment
Labels

Comments

@randolf-scholz
Copy link

Consider the following code

\newunicodechar{𝔸}{\mathds{a}}
\newunicodechar{𝔹}{\mathds{B}}
\newunicodechar{ℂ}{\mathds{C}}
\newunicodechar{𝔻}{\mathds{D}}
\newunicodechar{𝔼}{\mathds{E}}

When trying to block select the second curly brackets, TeXstudio selects the wrong characters in the 3rd line

image

The same issue is not present in other editors such as VS Code

image

I suspect the issue originals from coming from a different block in Unicode than the other double stroke characters and taking less bytes, so somehow TeXstudio counts only as 1 character, but it counts 𝔹 as 2 characters. This can be verified by the column number: right after TexStudio says we are at column 17, right after 𝔹 TeXstudio thinks we are at column 18.

I originally posted this issue here: https://tex.stackexchange.com/questions/644310/using-texstudio-with-unicode-incorrect-cursor-position

Environment

  • TeXstudio: 4.2.3
  • Qt: Using Qt Version 5.15.3, compiled with Qt 5.15.3 R
  • OS: Ubuntu 22.04 LTS
  • TeX distribution: texlive-2021
@randolf-scholz randolf-scholz changed the title TeXstudio Double counts Unicode Characters leading to wrong alignment TeXstudio double counts Unicode characters leading to wrong alignment Jun 21, 2022
@sunderme sunderme added the bug label Jul 1, 2022
@sunderme
Copy link
Member

sunderme commented Jul 3, 2022

the issue is that QString strores data as utf-16. 𝔸 uses two 16-bit characters, only one. QString does not abstract that behaviour and txs relies on character counting from QString.
Fixing this is complicated, since doing it right would touch quite a lot of code.
As the impact for now is minor, I leave it as is.

sunderme added a commit that referenced this issue Jul 3, 2022
@sunderme sunderme pinned this issue Jan 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants