diff --git a/src/characters/Character.h b/src/characters/Character.h index 0d3605db..4c4949f6 100644 --- a/src/characters/Character.h +++ b/src/characters/Character.h @@ -170,6 +170,6 @@ constexpr bool Character::equalsFormat(const Character &other) const return backgroundColor == other.backgroundColor && foregroundColor == other.foregroundColor && rendition == other.rendition; } } -Q_DECLARE_TYPEINFO(Konsole::Character, Q_PRIMITIVE_TYPE); +Q_DECLARE_TYPEINFO(Konsole::Character, Q_MOVABLE_TYPE); #endif // CHARACTER_H diff --git a/src/history/compact/CompactHistoryScroll.cpp b/src/history/compact/CompactHistoryScroll.cpp index 552926aa..e4e41afe 100644 --- a/src/history/compact/CompactHistoryScroll.cpp +++ b/src/history/compact/CompactHistoryScroll.cpp @@ -23,16 +23,16 @@ CompactHistoryScroll::CompactHistoryScroll(const unsigned int maxLineCount) setMaxNbLines(maxLineCount); } -void CompactHistoryScroll::removeFirstLine() +void CompactHistoryScroll::removeLinesFromTop(int lines) { if (_index.size() > 1) { - _flags.erase(_flags.begin()); + _flags.erase(_flags.begin(), _flags.begin() + lines); - const int removing = _index.front(); - std::transform(_index.begin() + 1, _index.end(), _index.begin(), [removing](int i) { + const int removing = _index[lines - 1]; + std::transform(_index.begin() + lines, _index.end(), _index.begin(), [removing](int i) { return i - removing; }); - _index.pop_back(); + _index.erase(_index.end() - lines, _index.end()); _cells.erase(_cells.begin(), _cells.begin() + removing); } else { @@ -49,8 +49,8 @@ void CompactHistoryScroll::addCells(const Character a[], const int count) _index.push_back(_cells.size()); _flags.push_back(LINE_DEFAULT); - if (_index.size() > _maxLineCount) { - removeFirstLine(); + if (_index.size() > _maxLineCount + 5) { + removeLinesFromTop(5); } } @@ -99,8 +99,9 @@ void CompactHistoryScroll::setMaxNbLines(const int lineCount) Q_ASSERT(lineCount >= 0); _maxLineCount = lineCount; - while (_index.size() > _maxLineCount) { - removeFirstLine(); + if (_index.size() > _maxLineCount) { + int linesToRemove = _index.size() - _maxLineCount; + removeLinesFromTop(linesToRemove); } } @@ -166,9 +167,10 @@ int CompactHistoryScroll::reflowLines(const int columns) _flags = std::move(newLine.flags); int deletedLines = 0; - while ((size_t)getLines() > _maxLineCount) { - removeFirstLine(); - ++deletedLines; + size_t totalLines = getLines(); + if (totalLines > _maxLineCount) { + deletedLines = totalLines - _maxLineCount; + removeLinesFromTop(deletedLines); } return deletedLines; diff --git a/src/history/compact/CompactHistoryScroll.h b/src/history/compact/CompactHistoryScroll.h index 6ce1e10b..01e7944e 100644 --- a/src/history/compact/CompactHistoryScroll.h +++ b/src/history/compact/CompactHistoryScroll.h @@ -45,7 +45,7 @@ private: size_t _maxLineCount; - void removeFirstLine(); + void removeLinesFromTop(int lines); inline int lineLen(const int line) const {