[texworks] [Qt-interest] Disappearing lines when using a syntax highlighter

Paul A Norman paul.a.norman at gmail.com
Tue Jul 12 09:47:13 CEST 2011

More Information on possibly related symptoms:

Sometimes when line numbers are working ok,

1. And I am at the left margin before any text (which starts
immediately to right), if I hit the return key, and then the space
bar, the text does not move to the right as anticipated.

In fact the area becomes "jammed".

2. If I break a line with the return key,sometimes the new line has an
automatic tab in, or I end up with the text against the left margin
and the new line is as explained above, and again the space bar will
not move the text inwards to the right.

----- configuration info -----
TeXworks version : 0.5r862 (official)
Install location : G:/latexportable/LaTexUtils/TeXWorks/texworks/TeXworks.exe
Library path     : G:/latexportable/LaTexUtils/TeXWorks/texworks/config\
pdfTeX location  : G:/LaTeXPortable/LatexUtils/MiTeX 2.8.3541
Operating system : Windows XP Professional Service Pack 3
Qt4 version      : 4.7.3 (build) / 4.7.3 (runtime)

On 11 July 2011 19:05, Paul A Norman <paul.a.norman at gmail.com> wrote:
> Good one Stefan!
> Paul
> On 11 July 2011 17:44, Stefan Löffler <st.loeffler at gmail.com> wrote:
>> Hi,
>> I'm a developer of the TeX editor project TeXworks that is based on the
>> Qt framework. About half a year ago, the problem of the disappearing
>> lines has been reported [1], but now I finally managed to reproduce it
>> in a minimal example (source code and test file attached).
>> Here's the problem: when I use a QSyntaxHighlighter-derived class and
>> call highlighter.rehighlight() in the initialization, several lines
>> simply vanish in the initial display. One has to resize the window
>> horizontally (presumably to cause a relayout of the text) to show those
>> lines.
>> This seems to depend on the Qt version used. So far, I've tested the
>> following ones:
>> gcc 4.5.2
>> - Qt 4.6.3 (debug) works
>> - Qt 4.7.2 (debug) fails, missing lines: 144--147, 154--157, 160--161,
>> 169--181
>> gcc 4.6.0
>> - Qt 4.7.3 fails, missing: 155-157, 160-161, 169-181
>> I'm not sure if this is also system-dependent?
>> A few things to note:
>> - this is independent of the window's initial size, but manual
>> horizontal resize works around the problem
>> - moving rehighlight() in front of show() apparently solve the problem
>> as well (though this might not be possible in real-life if rehighlight
>> is tied to signals and/or other parts of the code, e.g., for document
>> parsing)
>> - the missing lines depend on the highlighting definition (changing
>> "%.*$" to "%.+$" made lines 137--143 disappear with Qt 4.7.2)
>> - the cursor disappears when moving to hidden lines with the arrow keys
>> (the real app, TeXworks, crashes, presumably due to the "highlight
>> current line" feature using code from
>> http://doc.qt.nokia.com/latest/widgets-codeeditor.html)
>> Some additional debugging suggests that the text is properly split into
>> QTextBlocks, but that those are not (all) laid out properly into
>> QTextLines. But that internal layout code is fairly complex...
>> Does anyone have any hint as to where this issue comes form or how to
>> solve this?
>> Thanks in advance,
>> Stefan
>> [1] http://code.google.com/p/texworks/issues/detail?id=469
>> http://code.google.com/p/texworks/issues/detail?id=497
>> http://code.google.com/p/texworks/issues/detail?id=505

More information about the texworks mailing list