When the last line in history was marked as wrapped, the history reflow
algorithm could try to make an out-of-bound access.
These were found via repeteadly zooming-in and out in the amp.rs editor
(available through Rust's cargo tool). amp.rs writes in the normal
buffer (not in the alternate buffer).
While at it, add a Q_ASSERT in HistoryScrollFile::startOfLine() to
ensure parameters are in range. Note that after an addCells()/addLine()
pair, HistoryScrollFile::startOfLine(getLines) always has the same value
as _cells.len().
BUG: 436916
It is removing the vector of lines storage. Now it is using a similar
idea used in history file.
All chars are stored in a linear way, only the line indexes are
changed when reflowing.
No speed problem found when removing lines.
Double height lines are actually two lines, the first with the top part
of the characters, the second with the bottom part. Reflowing could lead
to situations where we render a top part, a double height line with its
top and bottom parts, and a bottom part, which looks weird.
While DECDHL/DECDWL lines are not wrapped at the correct column, now at
least reflowing doesn't clear line rendition attributes, so resizing
Konsole and going back to the original size always recovers the original
content, including double-height/double-width status of each line.
Reflowing double-height lines doesn't make much sense, since a
double-height line actually consists of a top (T) and a bottom (B)
line. Shrinking them could lead to TTBB lines, which look weird. At
least now going back to the original size brings back the original
content in all its glory.
- If the QObject has a parent, the parent will take care of deleting it
- Use std::unique_ptr to manage pointer member variable
- Use '= default' with empty destructors
- Fix initialization of QTimer in constructor initialization list
Those Classes are not QObject, so most of it's pointers could be changed
to smart pointers with no problems.
Problem found when using QList<std::unique_ptr>: it wasn't possible to
use it. I'm using std containers instead.
While testing I found a bug in CompactHistoryScroll add function, it
should append before check the vector size and not after, it was
returning a Size > Max Size, not equal.
Another Bug found in fixed size history scroll, it was not properly
reflowing the last line, a position problem when adding and removing
lines to keep a fixed size.
Moving the fixed size history reflow code to compactHistoryScroll file.
Screen file will not handle history reflow, unlimited scroll is
completely different from fixed size scroll reflow.
When using unlimited history and change to fixed history size, it will
move, limited by the fixed size, the history.
It will create a new CompactHistoryScroll, get the lines from the old
HistoryScrollFile, and delete the old HistoryScrollFile structure.
It is not reflowing unlimited history lines (there is no limit and it
can be very long), it just reflow screenlines and join the lines when it
get to history.
Unfortunately the code is still fragile and I froze konsole
a few times in a few minutes. This is something that konsole
really needs, but we need more time to squish all the bugs
we find.