Skip to content

Commit fa2e19c

Browse files
committed
GCoderDocument: Fix the wrong search direction for the next replacement
The class contains several similar functions with the same set of arguments: - findNext - replaceNext - replaceAll - highlightFindText - findText But findText has a different order of these arguments. Because of this there is a confusion inside the replaceNext function. This commit makes the order of the findText function arguments the same as the other functions.
1 parent d6a6ee6 commit fa2e19c

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

gcodeworkshop/include/gcoderdocument.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ public slots:
162162
bool maybeSave();
163163
void rehighlight();
164164
void detectHighlightMode();
165-
bool findText(const QString& text, bool findBackward, bool wholeWords, bool ignoreCase, bool ignoreComments = true);
165+
bool findText(const QString& text, bool wholeWords, bool ignoreCase, bool ignoreComments, bool backward);
166166

167167
private slots :
168168
void underLine();

gcodeworkshop/src/gcoderdocument.cpp

+8-8
Original file line numberDiff line numberDiff line change
@@ -788,7 +788,7 @@ bool GCoderDocument::findNext(QString textToFind,
788788

789789
textEdit()->blockSignals(true);
790790

791-
found = findText(textToFind, backward, wholeWords, ignoreCase, ignoreComments);
791+
found = findText(textToFind, wholeWords, ignoreCase, ignoreComments, backward);
792792

793793
if (!found) {
794794
cursor = textCursor();
@@ -802,7 +802,7 @@ bool GCoderDocument::findNext(QString textToFind,
802802

803803
setTextCursor(cursor);
804804

805-
found = findText(textToFind, backward, wholeWords, ignoreCase, ignoreComments);
805+
found = findText(textToFind, wholeWords, ignoreCase, ignoreComments, backward);
806806

807807
if (!found) {
808808
cursorOld.clearSelection();
@@ -843,7 +843,7 @@ bool GCoderDocument::replaceNext(QString textToFind,
843843
if (foundTextMatched(textToFind, selectedText())) {
844844
found = true;
845845
} else {
846-
found = findNext(textToFind, backward, wholeWords, ignoreCase, ignoreComments);
846+
found = findNext(textToFind, wholeWords, ignoreCase, ignoreComments, backward);
847847
}
848848

849849
if (found) {
@@ -908,12 +908,12 @@ bool GCoderDocument::replaceNext(QString textToFind,
908908
cr.endEditBlock();
909909
setTextCursor(cr);
910910

911-
found = findNext(textToFind, backward, wholeWords, ignoreCase, ignoreComments);
911+
found = findNext(textToFind, wholeWords, ignoreCase, ignoreComments, backward);
912912
}
913913

914914
textEdit()->blockSignals(false);
915915
cursorMoved();
916-
highlightFindText(textToFind, backward, wholeWords, ignoreCase, ignoreComments);
916+
highlightFindText(textToFind, wholeWords, ignoreCase, ignoreComments, backward);
917917

918918
return found;
919919
}
@@ -956,8 +956,8 @@ bool GCoderDocument::replaceAll(QString textToFind,
956956
return found;
957957
}
958958

959-
bool GCoderDocument::findText(const QString& text, bool findBackward, bool wholeWords, bool ignoreCase,
960-
bool ignoreComments)
959+
bool GCoderDocument::findText(const QString& text, bool wholeWords, bool ignoreCase,
960+
bool ignoreComments, bool backward)
961961
{
962962
bool inComment = false;
963963
bool found = false;
@@ -1023,7 +1023,7 @@ bool GCoderDocument::findText(const QString& text, bool findBackward, bool whole
10231023

10241024
do {
10251025
QTextDocument::FindFlags options{};
1026-
options = (findBackward ? QTextDocument::FindBackward : options) |
1026+
options = (backward ? QTextDocument::FindBackward : options) |
10271027
(wholeWords ? QTextDocument::FindWholeWords : options) |
10281028
(!ignoreCase ? QTextDocument::FindCaseSensitively : options);
10291029

0 commit comments

Comments
 (0)