Skip to content

Commit

Permalink
replaceAll handle scintilla bug(hope this is acceptable)
Browse files Browse the repository at this point in the history
replaceAll handle scintilla bug(hope this is acceptable)
  • Loading branch information
kipbits committed Mar 4, 2017
1 parent e0744a1 commit 1b51e51
Showing 1 changed file with 26 additions and 9 deletions.
35 changes: 26 additions & 9 deletions src/scintillaeditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -571,18 +571,35 @@ void ScintillaEditor::replaceSelectedText(const QString &newText)
if ((qsci->selectedText() != newText)&&(qsci->hasSelectedText())) qsci->replaceSelectedText(newText);
}

void ScintillaEditor::replaceAll(const QString &findText, const QString &replaceText)//QScintilla bug no longer an issue
{
if (qsci->findFirst(findText,
false /*re*/, false /*cs*/, false /*wo*/,
false /*wrap*/, true /*forward*/, 0, 0)) {
qsci->replace(replaceText);
while (qsci->findNext()) {
qsci->replace(replaceText);
}
void ScintillaEditor::replaceAll(const QString &findText, const QString &replaceText)
{
// We need to issue a Select All first due to a bug in QScintilla:
// It doesn't update the find range when just doing findFirst() + findNext() causing the search
// to end prematurely if the replaced string is larger than the selected string.
#if QSCINTILLA_VERSION >= 0x020903
// QScintilla bug seams to be fixed in 2.9.3
if (qsci->findFirst(findText,
false /*re*/, false /*cs*/, false /*wo*/,
false /*wrap*/, true /*forward*/, 0, 0)) {
#elif QSCINTILLA_VERSION >= 0x020700
qsci->selectAll();
if (qsci->findFirstInSelection(findText,
false /*re*/, false /*cs*/, false /*wo*/,
false /*wrap*/, true /*forward*/)) {
#else
// findFirstInSelection() was introduced in QScintilla 2.7
if (qsci->findFirst(findText,
false /*re*/, false /*cs*/, false /*wo*/,
false /*wrap*/, true /*forward*/, 0, 0)) {
#endif
qsci->replace(replaceText);
while (qsci->findNext()) {
qsci->replace(replaceText);
}
}
}


void ScintillaEditor::getRange(int *lineFrom, int *lineTo)
{
int indexFrom, indexTo;
Expand Down

0 comments on commit 1b51e51

Please sign in to comment.