texstudio icon indicating copy to clipboard operation
texstudio copied to clipboard

Inline math env with wrong highlighting

Open octaeder opened this issue 2 years ago • 7 comments

Environment

  • TeXstudio: current dev / 4.6.3
  • Qt: 6.6.0 / 6.5.2
  • OS: Win10
  • TeX distribution: miktex

Expected behavior

No error highlighting

Actual behavior

image

How to reproduce

Start txs without document. Press Ctrl+N, type doc, press Ctrl+Alt+Space, Enter to select document env, Del to remove placeholder, Ctrl+Shift+M , (, ), /, (, ), twice Crsr right. You may also fill in characters within parentheses pairs. Similar effects have been observed with inline math env. But this one is reproducible for me.

octaeder avatar Nov 30 '23 17:11 octaeder

Note: From scratch this issue is reproducible. When you continue editing this mismatch can disappear. This may indicate some internal representation error when the $$ env is inserted.

octaeder avatar Nov 30 '23 17:11 octaeder

not reproducible

sunderme avatar Dec 01 '23 17:12 sunderme

maybe another time or someone else can reproduce

octaeder avatar Dec 05 '23 22:12 octaeder

Since I see this very often I give it a second try. Three notes: When you type $, then \sin(x) then $ everything seems to be fine. By removing \sin(x) you can copy $$to clipboard. Using clipboard to insert $$ shows same issue as using ctrl+shift+m. So it seems that entering $ next to each other is not handled correctly. Inserting and deleting some character near or within the environment or current line normally fixes the issue.

Open a new editor, use ctrl+shift+m, type \sin(x) and then move cursor two times left to the x (i.e. the blinking line is left to the x, s. image). You can even walk around with the cursor and the red coloring appears when the cursor reaches ( or x.

grafik

Delete all and you can repeat the procedure. Often it doesn't work the fourth time but works again after that.

It happens that this has side effects: When such a 'defective' inline math env is within another environment (say from ntheorem), then alt+p may not be able do find/highlight the whole env that contains the inline math env and the preview breaks. This is shown here:

grafik

grafik

Be aware that the \end{Remark} is not within the selection for preview and thus preview fails.

octaeder avatar Feb 04 '24 18:02 octaeder

This is reproducible when starting txs with option --no-session

octaeder avatar Feb 04 '24 19:02 octaeder

to reproduce Adv. Editor option Auto Complete Parentheses needs to be checked

octaeder avatar Feb 10 '24 00:02 octaeder

not reproducible.

sunderme avatar Mar 08 '24 11:03 sunderme