Replace button in SQL Editor inserts text at cursor after a previous find

Each time the searched term or the dialog is closed, the find process in
the QScintilla widget is cancelled. This avoids the problem mentioned in
issue #1612 and similar others, like finding, then changing the searched
term and pressing Replace. In all these cases Replace only finds the next
term to be replaced without performing any actual replacement.
This commit is contained in:
mgrojo
2018-11-17 14:22:50 +01:00
parent ef7492adfb
commit 12b4fd91a7
2 changed files with 12 additions and 2 deletions
+11 -2
View File
@@ -32,6 +32,7 @@ void FindReplaceDialog::setExtendedScintilla(ExtendedScintilla* scintilla)
ui->replaceAllButton->setEnabled(isWriteable);
connect(m_scintilla, SIGNAL(destroyed()), this, SLOT(hide()));
connect(ui->findText, SIGNAL(editingFinished()), this, SLOT(cancelFind()));
}
bool FindReplaceDialog::findNext()
@@ -61,7 +62,8 @@ void FindReplaceDialog::show()
void FindReplaceDialog::replace()
{
m_scintilla->replace(ui->replaceWithText->text());
if (m_scintilla->hasSelectedText())
m_scintilla->replace(ui->replaceWithText->text());
findNext();
}
@@ -140,6 +142,11 @@ void FindReplaceDialog::replaceAll()
}
void FindReplaceDialog::cancelFind()
{
m_scintilla->findFirst(QString(), false, false, false, false);
clearIndicators();
}
void FindReplaceDialog::help()
{
QWhatsThis::enterWhatsThisMode();
@@ -154,7 +161,9 @@ void FindReplaceDialog::clearIndicators()
void FindReplaceDialog::close()
{
m_scintilla->clearSelection();
clearIndicators();
// Reset any previous find so it does not interfere with the next time
// the dialog is open.
cancelFind();
QDialog::close();
}
+1
View File
@@ -26,6 +26,7 @@ private slots:
void replace();
void findAll();
void replaceAll();
void cancelFind();
void help();
void close();
void reject() override;