texstudio-org / texstudio

TeXstudio is a fully featured LaTeX editor. Our goal is to make writing LaTeX documents as easy and comfortable as possible.
http://www.texstudio.org/
GNU General Public License v3.0
2.78k stars 344 forks source link

Bug: QCE render mode causes cursor to oddly offset after `\cite{...}` #1633

Open jmatta1 opened 3 years ago

jmatta1 commented 3 years ago

Normally in a line of text the visual location of the cursor on the screen precisely aligns with the location where text is inserted. This is the case on a line without a \cite{...} command and on a line with a \cite{...} command before the occurrence of the command. However, if the cursor is placed after a \cite{...} command the visual location of the cursor is misaligned with the insertion location of the text, or even where the editor things the cursor is in relation to characters.

Environment

Expected behavior

Regardless of render mode, if I place the cursor anywhere in the document, before or after a \cite{...} command the visual cursor location should be the location the editor believes the cursor to be relative to text and should be the location that newly typed text appears

Actual behavior

If the render mode is set to QCE in the Adv. Editor settings (marked as the recommended mode). Placing the cursor after a \cite{...} command causes the visual placement of the cursor to be offset from the text insertion location. In fact placing the cursor before the \cite{...} command and moving the cursor one character at a time through the text of the \cite{...} command leads me to believe that the causes is the larger bold letters not being accounted for correctly. If the render is set to be Qt then this does not occur.

Video of QCE mode bad text placement and misalignment of cursor location relative to edit location:

https://user-images.githubusercontent.com/5047947/119366410-f0fdd400-bc7e-11eb-8672-c6609d62e8a5.mov

Video of QCE mode broken movement of cursor while traversing \cite{...} command:

https://user-images.githubusercontent.com/5047947/119366506-0bd04880-bc7f-11eb-9395-4bc54b79d9ca.mov

Video of Qt mode correct text placement:

https://user-images.githubusercontent.com/5047947/119366619-286c8080-bc7f-11eb-848c-ea73ef6789ca.mov

How to reproduce

Create a document with a separate BibTeX file and cite something from that file. Watch in horror as your typing no longer goes where you think it is going to.

If I had to guess, I would think that somehow the QCE renderer is not properly accounting for the extra width of the bold characters in the citation names.

sunderme commented 3 years ago

please post the sytanx highlighting settings ? Are they changed ?

jmatta1 commented 3 years ago

The syntax highlighting settings are indeed changed. Attached is my session file with the changes. (I set the file extention to .txt instead of .txsprofile to make GitHub happy) dark_syntax_profile.txt

Interestingly, I used the options menu to save that profile, load default settings, restart TexStudio, then load my older session profile, restart TexStudio again, and the problem seems to have disappeared, bibtex citations no longer seem to be bolded/made larger, and their color seems to be darker than in the attached videos... the heck?

And now through nothing more than loading and unloading TexStudio, reverting default settings, and loading the dark_syntax_profile that I attached repeatedly I have the system doing it again. 🤦

jmatta1 commented 3 years ago

I have determined the trigger for the bug. It was a mistake on my part, possibly a stray click and I am not sure how it only sometimes gets saved out by the profile. The font family for "Citation Present" was set to Arial Black instead of <default> this loads a non-fixed-width font into the middle of the fixed width fonts and confuses things I think.

While I have found a fix, I think this is still a bug. Varying fonts within a single line doesn't feel like it breaks things (though it does feel like it would be the kind of easy to overlook corner case that causes things to break.

Attached is a profile that actually has the "Arial Black" setting, I have no idea why it doesn't always load, I hope this has clarified somewhat the steps to reproduce. If desired I can go back and edit my opener. bad_dark_syntax_profile.txt

sunderme commented 3 years ago

when somebody wants to dig in qce code. low priority