Commit 34a96d88 authored by hjk's avatar hjk

debugger: add manual test for (too) long evaluation

parent 09b04caf
......@@ -867,6 +867,7 @@ public:
QString selectText(const Range &range) const;
void setCurrentRange(const Range &range);
Range currentRange() const { return Range(position(), anchor(), m_rangemode); }
Range rangeFromCurrentLine() const;
void yankText(const Range &range, int toregister = '"');
......@@ -3088,6 +3089,15 @@ void FakeVimHandler::Private::setCurrentRange(const Range &range)
m_rangemode = range.rangemode;
}
Range FakeVimHandler::Private::rangeFromCurrentLine() const
{
Range range;
int line = cursorLine() + 1;
range.beginPos = firstPositionInLine(line);
range.endPos = lastPositionInLine(line) + 1;
return range;
}
// use handleExCommand for invoking commands that might move the cursor
void FakeVimHandler::Private::handleCommand(const QString &cmd)
{
......@@ -3141,8 +3151,9 @@ bool FakeVimHandler::Private::handleExSubstituteCommand(const ExCommand &cmd)
if (flags.contains('i'))
pattern.setCaseSensitivity(Qt::CaseInsensitive);
const bool global = flags.contains('g');
const int beginLine = lineForPosition(cmd.range.beginPos);
const int endLine = lineForPosition(cmd.range.endPos);
const Range range = cmd.range.endPos == 0 ? rangeFromCurrentLine() : cmd.range;
const int beginLine = lineForPosition(range.beginPos);
const int endLine = lineForPosition(range.endPos);
beginEditBlock();
for (int line = endLine; line >= beginLine; --line) {
QString origText = lineContents(line);
......@@ -3357,9 +3368,10 @@ bool FakeVimHandler::Private::handleExDeleteCommand(const ExCommand &cmd)
if (!cmd.matches("d", "delete"))
return false;
setCurrentRange(cmd.range);
Range range = cmd.range.endPos == 0 ? rangeFromCurrentLine() : cmd.range;
setCurrentRange(range);
QString reg = cmd.args;
QString text = selectText(cmd.range);
QString text = selectText(range);
removeText(currentRange());
if (!reg.isEmpty()) {
Register &r = g.registers[reg.at(0).unicode()];
......@@ -3487,15 +3499,20 @@ bool FakeVimHandler::Private::handleExShiftCommand(const ExCommand &cmd)
if (cmd.cmd != "<" && cmd.cmd != ">")
return false;
setCurrentRange(cmd.range);
int count = qMin(1, cmd.args.toInt());
Range range = cmd.range;
if (cmd.range.endPos == 0) {
range = rangeFromCurrentLine();
--range.endPos;
}
setCurrentRange(range);
int count = qMax(1, cmd.args.toInt());
if (cmd.cmd == "<")
shiftRegionLeft(count);
else
shiftRegionRight(count);
leaveVisualMode();
const int beginLine = lineForPosition(cmd.range.beginPos);
const int endLine = lineForPosition(cmd.range.endPos);
const int beginLine = lineForPosition(range.beginPos);
const int endLine = lineForPosition(range.endPos);
showBlackMessage(FakeVimHandler::tr("%n lines %1ed %2 time", 0,
(endLine - beginLine + 1)).arg(cmd.cmd).arg(count));
return true;
......
......@@ -1549,6 +1549,16 @@ void testQUrl()
(void) url;
}
void testLongEvaluation()
{
QDateTime time = QDateTime::currentDateTime();
QVector<QDateTime> bigv;
for (int i = 0; i < 10000; ++i)
bigv.append(time);
int s = bigv.size();
++s;
}
#ifdef FOP
......@@ -2523,6 +2533,7 @@ void testMPI()
int main(int argc, char *argv[])
{
testLongEvaluation();
testMPI();
testStuffA();
testPrivate();
......
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