From d3f736d8732696a2cc95234fb0f970619ee6fb66 Mon Sep 17 00:00:00 2001 From: Oskar Linde Date: Sun, 2 Feb 2014 02:09:09 +0100 Subject: [PATCH] Editor: Fix bug where replaceAll could enter an infinite loop --- src/mainwin.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/mainwin.cc b/src/mainwin.cc index 87f7e019..d51bae00 100644 --- a/src/mainwin.cc +++ b/src/mainwin.cc @@ -1166,9 +1166,14 @@ void MainWindow::replace() { } void MainWindow::replaceAll() { - while (findOperation()) { + QTextCursor old_cursor = editor->textCursor(); + QTextCursor tmp_cursor = old_cursor; + tmp_cursor.movePosition(QTextCursor::Start); + editor->setTextCursor(tmp_cursor); + while (editor->find(findInputField->text())) { editor->textCursor().insertText(replaceInputField->text()); } + editor->setTextCursor(old_cursor); } void MainWindow::findNext()