mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-05-01 17:39:42 -05:00
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:
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ private slots:
|
||||
void replace();
|
||||
void findAll();
|
||||
void replaceAll();
|
||||
void cancelFind();
|
||||
void help();
|
||||
void close();
|
||||
void reject() override;
|
||||
|
||||
Reference in New Issue
Block a user