Skip to content

Commit 8b452f6

Browse files
committed
openscad#1264 Backported to QScintilla 2.7, left a small bug when using 2.7 but we can live with it
1 parent 5ad4b13 commit 8b452f6

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/scintillaeditor.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -515,20 +515,21 @@ void ScintillaEditor::replaceAll(const QString &findText, const QString &replace
515515
// We need to issue a Select All first due to a bug in QScintilla:
516516
// It doesn't update the find range when just doing findFirst() + findNext() causing the search
517517
// to end prematurely if the replaced string is larger than the selected string.
518+
#if QSCINTILLA_VERSION >= 0x020700
518519
qsci->selectAll();
519520
if (qsci->findFirstInSelection(findText,
520521
false /*re*/, false /*cs*/, false /*wo*/,
521522
false /*wrap*/, true /*forward*/)) {
523+
#else
524+
// findFirstInSelection() was introduced in QScintilla 2.7
525+
if (qsci->findFirst(findText,
526+
false /*re*/, false /*cs*/, false /*wo*/,
527+
false /*wrap*/, true /*forward*/, 0, 0)) {
528+
#endif
522529
qsci->replace(replaceText);
523530
while (qsci->findNext()) {
524-
int lineFrom, indexFrom, lineTo, indexTo;
525-
qsci->getSelection(&lineFrom, &indexFrom, &lineTo, &indexTo);
526-
PRINTDB("replacing selection at line %d-%d, index %d-%d", lineFrom % lineTo % indexFrom % indexTo);
527531
qsci->replace(replaceText);
528532
}
529-
int lineFrom, indexFrom, lineTo, indexTo;
530-
qsci->getSelection(&lineFrom, &indexFrom, &lineTo, &indexTo);
531-
PRINTDB("Last: %d-%d, index %d-%d", lineFrom % lineTo % indexFrom % indexTo);
532533
}
533534
}
534535

0 commit comments

Comments
 (0)