Bug 387910 - Text selection is very slow when there is long lines
Summary: Text selection is very slow when there is long lines
Status: RESOLVED DUPLICATE of bug 345775
Alias: None
Product: kate
Classification: Applications
Component: kwrite (show other bugs)
Version: 17.08.1
Platform: Fedora RPMs Linux
: NOR normal
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
: 390645 407042 (view as bug list)
Depends on:
Blocks:
 
Reported: 2017-12-14 19:08 UTC by b2.temp
Modified: 2019-06-10 19:51 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
typical file with long lines (2.81 KB, text/x-dsrc)
2017-12-14 19:08 UTC, b2.temp
Details

Note You need to log in before you can comment on or make changes to this bug.
Description b2.temp 2017-12-14 19:08:56 UTC
Created attachment 109380 [details]
typical file with long lines

I use a tool to generates tables in a source code. Result contains 3 very long LOCs (~1000 columns). Trying to select them in In KWrite 17.08.1  and using SHIFT + CTRL + ARROWS is very slow, there's a lag for each ARROW keystroke.

I attach a demo file, play with selection to verify the bug. Just CTRL + A should show the issue. Then reduce the selection with SHIFT + CTRL + LEFT ARROW to see how it is annoying.

The problem happens even with no syntax highlihgting and with max line size set to 4096.
Comment 1 Christoph Feck 2018-06-27 21:23:33 UTC
*** Bug 390645 has been marked as a duplicate of this bug. ***
Comment 2 b2.temp 2019-04-04 13:25:39 UTC
Nowadays, 2019, it seems that the problem only happens with highligthning toggled on.
Comment 3 FeepingCreature 2019-04-04 14:17:13 UTC
To add: hooking up gdb and upping the line length to 15k to make it easier to debug, the backtrace generally looks like

#1  QTextLine::draw(QPainter*, QPointF const&, QTextLayout::FormatRange const*) const ()
#2  QTextLayout::draw(QPainter*, QPointF const&, QVector<QTextLayout::FormatRange> const&, QRectF const&) const ()
#3  KateRenderer::paintTextLine (this=this@entry=0x555633e445c0, paint=..., range=..., xStart=xStart@entry=0, xEnd=xEnd@entry=972, cursor=cursor@entry=0x7ffdad493418, flags=...)
#4  KateViewInternal::paintEvent (this=0x555633dc4670, e=0x7ffdad493720)
#5  QWidget::event(QEvent*) ()

There seems to only be one call to QTextLayout::draw causing the majority of the slowdown.
Comment 4 Buovjaga 2019-04-16 19:59:00 UTC
(In reply to b2.temp from comment #2)
> Nowadays, 2019, it seems that the problem only happens with highligthning
> toggled on.

Looks like there is ongoing work on this:
https://phabricator.kde.org/D17241
"WIP:Disable highlighting after 512 characters on a line."

(In reply to FeepingCreature from comment #3)
> There seems to only be one call to QTextLayout::draw causing the majority of
> the slowdown.

This old (still open) Qt issue seems to match the topic of the report:
https://bugreports.qt.io/browse/QTBUG-21699
"QTextDocumentLayout::draw() is slow if there is text selection"
Quote: "its seems that QTextLayout is still used for text rendering, making it possible that this problem is present also on Qt5"

I actually don't repro the slowness with attachment 109380 [details], but have constantly ran into the issue of long lines causing Kate to basically hang. Unzip any ODF document and open its content.xml to experience it. I always have to beautify XML to work with it. Notepad++, for example, has never had these problems.
Comment 5 Christoph Feck 2019-05-14 20:22:49 UTC
*** Bug 407042 has been marked as a duplicate of this bug. ***
Comment 6 Christoph Cullmann 2019-06-10 19:51:53 UTC
The selection issue is IMHO fixed.
The issue with the highlighting not.
Actually, long lines create 10000ths of highlighting ranges, we will fix this in bug 345775.

*** This bug has been marked as a duplicate of bug 345775 ***