Bug 392926 - KTextEditor scrollbar preview and mini map do not respect word wrapping
Summary: KTextEditor scrollbar preview and mini map do not respect word wrapping
Status: REOPENED
Alias: None
Product: frameworks-ktexteditor
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: 5.76.0
Platform: Gentoo Packages Linux
: NOR normal
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-04-09 12:08 UTC by Till Schäfer
Modified: 2024-01-14 20:47 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
screenshot of kate with wrapped lines, the scrollbar preview and the mini map (297.02 KB, image/png)
2018-04-09 12:08 UTC, Till Schäfer
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Till Schäfer 2018-04-09 12:08:12 UTC
Created attachment 111920 [details]
screenshot of kate with wrapped lines, the scrollbar preview and the mini map

If word wrap is enabled the preview and the mini map still display the unwrapped version, this also results in a miscalculation of the mini map sliding window. See attached screenshot.
Comment 1 Dominik Haumann 2018-04-10 17:52:18 UTC
True, the text preview should use the same visual word wrap if dynamic word wrap is enabled. The layout cache should support this already.
Comment 2 Dominik Haumann 2018-08-15 22:12:26 UTC
Btw, the minimap is a representation also of how the scrollbar works. The scrollbar always scrolls by real lines, never by dynamically wrapped lines.
Also, the minimap is just there to give the user a hint about the document contents, so I don't think the scrollbar contents needs to be wrapped (in fact, it would be wrong because of the real-line scrolling). So the minimpa-part is a wont-fix.
Comment 3 Dominik Haumann 2018-08-15 22:21:49 UTC
We just discussed that again: The text preview does not have the same width as the text view itself anyways, so proportions do not match. Dynamically wrapping lines may be more confusing than helping here.

For now, this is a wont-fix. Maybe we will reconsider in the future. Or you provide a patch so we can try this out. :-)
Comment 4 Till Schäfer 2018-08-16 10:01:42 UTC
I am reopening this bug, because I think this is wrong from a usability POV for the following reasons:

1) The scrollbar preview should at least show the correct region of the text, that is shown in the window. However, if the wrapping is not displayed in the preview, the region is to large (see screenshot). Changing the preview window height would be even more confusing during scrolling.

2) Even if the scroll behavior is "by line" one should consider changing this. For very long lines (that are longer the the complete kate window) it is otherwise impossible to display the whole line with word wrap enabled! 
The scroll behavior was changed recently in Bug 256561 for wheel and touchpad scrolling. Thus, the preview does not match this scrolling behavior anymore. How do you display "wrapped line scrolls" in this case? In the bug it is also mentioned, that it was already possible before this change to scroll by a wrapped line with the shortcut ctrl+up/down.

3) Its just confusing to have two different representations of the same text. As one is unable to actually read the text is the preview, one actually depends on the line length representation for orientation, i.e., the visual outer hull of the text. If this is different from the preview, the preview is nearly useless.
Comment 5 Sven Brauch 2018-08-16 12:12:41 UTC
1) To me the displayed region looks correct.

2) The first part of this paragraph I don't understand, sorry. The second part is inaccurate, since the change only applies to wheel scrolling; the scrollbar still scrolls by real lines, and this will most probably never change. You'd otherwise need to layout all the lines when opening a document, which you do not want to do.

3) For the same reason, it IMO is not possible to paint wrapped lines in the scrollbar. It will break the 1:1 correspondence between height and scroll position.
Comment 6 Dominik Haumann 2018-08-16 12:36:31 UTC
Ok, I can see the point for very long lines as in your screenshot, so I will reopen for now.

(May I suggest, though, that you wrap your lines from time to time? It's good practice anyways, especially when having the file version controlled. Then, looking at the diff, not the entire paragraph changed, but only parts of it. But maybe that is not your use case.)
Comment 7 Till Schäfer 2018-08-16 13:51:00 UTC
I respect your choice about whether this is fixable. However, I try to explain myself, to avoid misunderstandings.

@Sven Brauch:
1) The blue rectangle in the preview is much larger than the displayed "edit area", i.e., the real editor.

2) Consider a line, that is very very long. If it is such long, that it does not fit in the whole edit area, it is impossible to scroll to the end of the line with "per line scrolling" of the scroll bar. Furthermore, a "wrapped line scroll" (e.g., by ctrl+up/down) will not always change the scroll bar position (i.e. the scroll bar is jumpy). That's why I proposed to change that scroll bar behavior as well

3) that's why I suggested to change that scrolling behavior as well (see point 2)

@Dominik Haumann: 
I agree, that very long lines should be avoided. But sometimes you just have files from other people, converted texts from LibreOffice/Word (where one paragraph is represented by a line) or you have scientific content (such as DNA-strings, etc).
Comment 8 Alexander Potashev 2019-08-08 17:38:10 UTC
Same problem here with KDE Frameworks 5.59.0.
Comment 9 Alexander Potashev 2019-08-08 17:45:21 UTC
My use case:
  I paste a long line (many kilobytes) from a software debug log output, then try to scroll it.

Because of this bug, I cannot scroll using the scrollbar. I can scroll with PgUp/PgDown or with mouse wheel, but it's slow (max. 30 pages/second). And because the scrollbar preview height is tiny, I cannot see at what percentage I am currently in the file: close to the beginning, or somewhere is the middle of the file, etc.

The scrollbar was usable for this particular use case before the scrollbar previous was introduced. Thus it is a regression.
Comment 10 Alexander Potashev 2019-08-08 17:49:50 UTC
(In reply to Alexander Potashev from comment #9)
> Because of this bug, I cannot scroll using the scrollbar. I can scroll with
> PgUp/PgDown or with mouse wheel, but it's slow (max. 30 pages/second). And

Also, I cannot use PgUp/PgDown if I'm about to check matching brackets: I need to set the text cursor position to a bracket and keep it unchanged, and pressing PgUp/PgDown would break it. In this case the only option is scrolling with mouse wheel, and it's just 3 lines per rotation - very time consuming.