Commit f4643a0d authored by Carlos Alves's avatar Carlos Alves Committed by Kurt Hindenburg
Browse files

Limit the history reflow

Set a limit to 20,000 lines
parent 9e745ea5
......@@ -69,6 +69,7 @@ public:
protected:
HistoryType *_historyType;
const int MAX_REFLOW_LINES = 20000;
};
}
......
......@@ -138,6 +138,9 @@ int HistoryScrollFile::reflowLines(int columns)
// First all changes are saved on an auxiliary file, no real index is changed
int currentPos = 0;
if (getLines() > MAX_REFLOW_LINES) {
currentPos = getLines() - MAX_REFLOW_LINES;
}
while (currentPos < getLines()) {
qint64 startLine = startOfLine(currentPos);
qint64 endLine = startOfLine(currentPos + 1);
......@@ -160,8 +163,14 @@ int HistoryScrollFile::reflowLines(int columns)
}
// Erase data from index and flag data
_index.removeLast(0);
_lineflags.removeLast(0);
if (getLines() > MAX_REFLOW_LINES) {
currentPos = getLines() - MAX_REFLOW_LINES;
_index.removeLast(currentPos * sizeof(qint64));
_lineflags.removeLast(currentPos * sizeof(char));
} else {
_index.removeLast(0);
_lineflags.removeLast(0);
}
// Now save the new indexes and properties to proper files
int totalLines = reflowFile->len() / sizeof(reflowData);
......
......@@ -149,8 +149,6 @@ bool CompactHistoryScroll::isWrappedLine(int lineNumber)
int CompactHistoryScroll::reflowLines(int columns)
{
// Join the line and move the data to next line if needed
auto getCharacterBuffer = [](int size) {
static QVector<Character> characterBuffer(1024);
if (characterBuffer.count() < size) {
......@@ -160,8 +158,12 @@ int CompactHistoryScroll::reflowLines(int columns)
return characterBuffer.data();
};
// Join the line and move the data to next line if needed
int removedLines = 0;
int currentPos = 0;
if (getLines() > MAX_REFLOW_LINES) {
currentPos = getLines() - MAX_REFLOW_LINES;
}
while (currentPos < getLines()) {
int curr_linelen = getLineLen(currentPos);
// Join wrapped line in current history position
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment