Texstudio: Equation Preview issue in 3.0.0

Created on 28 Aug 2020  路  15Comments  路  Source: texstudio-org/texstudio


Environment

  • TeXstudio: 3.0.0
  • Qt: 5.12.1
  • OS: Windows 10, x64, version 1909
  • TeX distribution: miktex

Expected behavior

When I have the setting "Show preview as tooltip on formulas in editor" enabled, when my cursor hovers over a formula, the equation appears as a tooltip automatically. This should not depend on if math mode is entered using $ ... $, $$ ... $$, or \[...\]

Actual behavior

No tooltip appears and the log does not show any activity unless the formula is bound by \[...\]. That one works.

How to reproduce

Open
glitch.tex.txt
with all default settings and "Show preview as tooltip on formulas in editor" enabled. Notice how only the last of the three equations preview.

Most helpful comment

Build of latest codebase works fine on Linux, so I will try to build from source on Windows to see whether the problem will persist.

All 15 comments

Just tested TXS 3.0.0 on Windows 7 + TexLive
Formula popup works as expected. However you have to hover the mouse pointer over the opening/closing math tag $ or $$ or \[ or ']'. Another way to invoke the tooltip is to hover the mouse pointer on the whitespace after the closing math tag.

Just checked again, none of those work on windows 10, except for with \[...\]
That was the behavior I got on windows 10 with 2.12.22, so I'm not sure when that stopped working

Actually you are right. For whatever reason on the Windows machine I had 2.12.18 instead of 3.0.0. I just checked latest dev. build (3.0.1) it does not display tooltips. Let me check it why that happens.

Build of latest codebase works fine on Linux, so I will try to build from source on Windows to see whether the problem will persist.

The problem persists even with TXS built from source.

It seems that LatexEditorView::parenthizedTextSelection fails because QDocumentCursor::getMatchingPair fails.
I will investigate it in more detail and then will prepare a PR with a fix.

Problem probably comes from $ not being part of qcodeedit syntax highlighting (qxs) any more

@sunderme
I think you are correct.

It seems that line 8, which is

    $ \not \exists $

has an empty QDocumentLineHandle::m_parens
That is its the couple of $ is not added to the parentheses vector for that line.

Just for your information this is the backtrace. Frame 0 is where QDocumentLine::parentheses returns the empty vector of parentheses

#0  QDocumentLine::parentheses (this=0x28cc1c)
    at src/qcodeedit/lib/document/qdocumentline.cpp:619
#1  0x006d2f42 in QNFADefinition::getPMatches (this=0x495db800, c=..., 
    matches=...) at src/qcodeedit/lib/qnfa/qnfadefinition.cpp:473
#2  0x006d3209 in QNFADefinition::getMatches (this=0x495db800, c=...)
    at src/qcodeedit/lib/qnfa/qnfadefinition.cpp:531
#3  0x0069d198 in QDocumentCursorHandle::getMatchingPair (this=0x4df47c58, 
    from=..., to=..., maximal=true)
    at src/qcodeedit/lib/document/qdocument.cpp:6432
#4  0x006abd38 in QDocumentCursor::getMatchingPair (this=<incomplete type>, 
    from=..., to=..., maximal=true)
    at src/qcodeedit/lib/document/qdocumentcursor.cpp:989
#5  0x004eb16b in LatexEditorView::parenthizedTextSelection (this=0x4e1c2a60, 
    cursor=..., includeParentheses=true) at src/latexeditorview.cpp:2861
#6  0x004e6038 in LatexEditorView::showMathEnvPreview (this=0x4e1c2a60, 
    cursor=..., command=..., environment=..., pos=...)
    at src/latexeditorview.cpp:2344
#7  0x004e6ff3 in LatexEditorView::mouseHovered (this=0x0, pos=...)
    at src/latexeditorview.cpp:2440
#8  0x0074c613 in LatexEditorView::qt_static_metacall (_o=0x4e1c2a60, 
    _c=InvokeMetaMethod, _id=69, _a=0x28d598) at moc_latexeditorview.cpp:588
#9  0x0ef50a12 in QMetaObject::activate (sender=<optimized out>, 
    sender@entry=0x4e1c2ca0, signalOffset=<optimized out>, 
    local_signal_index=<optimized out>, local_signal_index@entry=12, 
    argv=<optimized out>, argv@entry=0x28d598) at kernel\qobject.cpp:3803
#10 0x0ef50ca1 in QMetaObject::activate (sender=0x4e1c2ca0, 
    m=0x9b9374 <QEditor::staticMetaObject>, local_signal_index=12, 
    argv=0x28d598) at kernel\qobject.cpp:3656
#11 0x00762de3 in QEditor::hovered (this=0x4e1c2ca0, _t1=...)
    at moc_qeditor.cpp:1330
#12 0x0066c378 in QEditor::event (this=0x4e1c2ca0, e=0x28d6f0)
    at src/qcodeedit/lib/qeditor.cpp:3065
#13 0x2e95830d in QApplicationPrivate::notify_helper (
    this=this@entry=0x43e72770, receiver=receiver@entry=0x4e1c2ca0, 
    e=e@entry=0x28d6f0) at kernel\qapplication.cpp:3700
#14 0x2e960232 in QApplication::notify (this=0x28fe14, receiver=0x4e1c25b8, 
    e=0x28d974) at kernel\qapplication.cpp:3366
#15 0x0ef28742 in QCoreApplication::notifyInternal2 (
    receiver=receiver@entry=0x4e1c25b8, event=event@entry=0x28d974)
    at kernel\qcoreapplication.cpp:1088
#16 0x0ef289a7 in QCoreApplication::sendEvent (receiver=0x4e1c25b8, 
    event=0x28d974) at kernel\qcoreapplication.cpp:1476
#17 0x2e95da69 in QApplication::event (this=0x28fe14, e=0x28dd60)
    at kernel\qapplication.cpp:1928
#18 0x0050e53c in TexstudioApp::event (this=0x28fe14, event=0x28dd60)
    at src/main.cpp:107
#19 0x2e95830d in QApplicationPrivate::notify_helper (
    this=this@entry=0x43e72770, receiver=receiver@entry=0x28fe14, 
    e=e@entry=0x28dd60) at kernel\qapplication.cpp:3700
#20 0x2e95f209 in QApplication::notify (this=0x28fe14, receiver=0x28fe14, 
    e=0x28dd60) at kernel\qapplication.cpp:3056
#21 0x0ef28742 in QCoreApplication::notifyInternal2 (
    receiver=receiver@entry=0x28fe14, event=event@entry=0x28dd60)
    at kernel\qcoreapplication.cpp:1088
#22 0x0ef289a7 in QCoreApplication::sendEvent (receiver=0x28fe14, 
    event=0x28dd60) at kernel\qcoreapplication.cpp:1476
#23 0x0ef7aaa7 in QEventDispatcherWin32Private::sendTimerEvent (
    this=this@entry=0x43e788c8, timerId=<optimized out>, timerId@entry=22)
    at kernel\qeventdispatcher_win.cpp:455
#24 0x0ef7acfa in qt_internal_proc(HWND__*, unsigned int, unsigned int, long)@16 (hwnd=0x30426, message=275, wp=22, lp=0)
    at kernel\qeventdispatcher_win.cpp:239
#25 0x764262fa in gapfnScSendMessage () from C:\Windows\syswow64\user32.dll
#26 0x00030426 in ?? ()
#27 0x76426d3a in USER32!GetThreadDesktop ()
   from C:\Windows\syswow64\user32.dll
#28 0x0ef7aae1 in QEventDispatcherWin32Private::sendTimerEvent (
    this=<optimized out>, timerId=<optimized out>)
    at kernel\qeventdispatcher_win.cpp:454
#29 0x00000000 in ?? ()

@sunderme
Funny thing is that preview tooltips work fine under Fedora 32 + latest TXS. However I am installing TXS from a custom RPM so I guess I pack an old .qnfa file when I build the RPM.

What would be the correct fix? Return the definitions in utilities\qxs\tex.qnfa and more specifically

<context id="mathmode$$" format="numbers" transparency="true">

?
I am not very fluent with qnfa, so you probably can implement the fix better than me...

I will change the system to use the token system instead of qnfa parenthesis...

OK, great. Thank you!

However I still don't understand why preview tooltip works just fine under Linux. I checked my .rpm file and it doesn't look like I bundle an old .qfna file. I guess I will investigate that in more detail tomorrow...

OK, found it.
Somehow I have an old leftover file in /root/.config/texstudio/languages/tex.qnfa which is from Apr/2019.
I guess TXS happily picks it up and that's why $ and $$ tooltips worked for me just fine under Linux.

why was this closed? It is still a bug in the windows version

It has been fixed in the github source tree. The windows dev. builds work correctly for me. You can download one from texstudio.org and test it yourself.

ah, it does. I thought the link to it would be posted here

Was this page helpful?
0 / 5 - 0 ratings