Skip to content

Commit

Permalink
Editor widget: make sure that our highlighting is cleared whenever ne…
Browse files Browse the repository at this point in the history
…cessary (#1414).
  • Loading branch information
agarny committed May 17, 2018
1 parent 2ed1042 commit 4407897
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
24 changes: 18 additions & 6 deletions src/plugins/widget/EditorWidget/src/editorwidget.cpp
Expand Up @@ -589,6 +589,8 @@ void EditorWidget::setFindReplaceVisible(bool pVisible)
} else {
mFindReplace->selectFindText();
}
} else {
clearHighlighting();
}

// Show/hide our find/replace widget
Expand Down Expand Up @@ -704,6 +706,18 @@ void EditorWidget::replaceAndFind()

//==============================================================================

void EditorWidget::clearHighlighting()
{
// Clear the current highlighting

int lastLine, lastIndex;

mEditor->lineIndexFromPosition(mEditor->text().length(), &lastLine, &lastIndex);
mEditor->clearIndicatorRange(0, 0, lastLine, lastIndex, mHighlightIndicatorNumber);
}

//==============================================================================

void EditorWidget::doHighlightAllOrReplaceAll(bool pHighlightAll)
{
// Highlight/replace all the occurences of the text
Expand All @@ -715,12 +729,8 @@ void EditorWidget::doHighlightAllOrReplaceAll(bool pHighlightAll)

// Clear any previous hihghlighting, if needed

if (pHighlightAll) {
int lastLine, lastIndex;

mEditor->lineIndexFromPosition(mEditor->text().length(), &lastLine, &lastIndex);
mEditor->clearIndicatorRange(0, 0, lastLine, lastIndex, mHighlightIndicatorNumber);
}
if (pHighlightAll)
clearHighlighting();

// Keep track of the first visible line and of our position

Expand Down Expand Up @@ -894,6 +904,8 @@ void EditorWidget::findTextChanged(const QString &pText)
// original position

if (pText.isEmpty()) {
clearHighlighting();

mEditor->setSelection(mCurrentLine, mCurrentColumn,
mCurrentLine, mCurrentColumn);
} else {
Expand Down
1 change: 1 addition & 0 deletions src/plugins/widget/EditorWidget/src/editorwidget.h
Expand Up @@ -159,6 +159,7 @@ class EDITORWIDGET_EXPORT EditorWidget : public Core::Widget

bool findText(const QString &pText, bool pForward);

void clearHighlighting();
void doHighlightAllOrReplaceAll(bool pHighlightAll);

signals:
Expand Down

0 comments on commit 4407897

Please sign in to comment.