fix #292652: Empty lines become smaller

This commit is contained in:
DangWang 2020-04-18 00:30:48 +03:00
parent dcb744ca20
commit 0998fffc66
2 changed files with 13 additions and 0 deletions

View file

@ -817,6 +817,16 @@ void TextBlock::insert(TextCursor* cursor, const QString& s)
}
}
//---------------------------------------------------------
// insertEmptyFragment
//---------------------------------------------------------
void TextBlock::insertEmptyFragment(TextCursor* cursor)
{
if (_fragments.size() == 0 || _fragments.at(0).text != "")
_fragments.insert(0, TextFragment(cursor, ""));
}
//---------------------------------------------------------
// fragment
// inputs:
@ -1248,6 +1258,8 @@ void TextBase::createLayout()
else if (c == '\n') {
if (rows() <= cursor.row())
_layout.append(TextBlock());
if(_layout[cursor.row()].fragments().size() == 0)
_layout[cursor.row()].insertEmptyFragment(&cursor); // used to preserve the Font size of the line (font info is held in TextFragments, see PR #5881)
_layout[cursor.row()].setEol(true);
cursor.setRow(cursor.row() + 1);
cursor.setColumn(0);

View file

@ -193,6 +193,7 @@ class TextBlock {
QRectF boundingRect(int col1, int col2, const TextBase*) const;
int columns() const;
void insert(TextCursor*, const QString&);
void insertEmptyFragment(TextCursor*);
QString remove(int column);
QString remove(int start, int n);
int column(qreal x, TextBase*) const;