diff options
| author | Mike Skec <skec@protonmail.ch> | 2021-02-09 17:55:48 +1100 |
|---|---|---|
| committer | Felix Queißner <felix@ib-queissner.de> | 2021-02-09 10:18:41 +0100 |
| commit | 08e2184c9f77fa627d33c2de08addae934a2308f (patch) | |
| tree | 89647084377e70c58126973df22605de55755c96 /src/browsertab.cpp | |
| parent | 0843ee2dada57255c29425f7b598ab3b258e4641 (diff) | |
| download | kristall-08e2184c9f77fa627d33c2de08addae934a2308f.tar.gz | |
searchbox: fix moving to top/bottom of page during search
When searching for something that wasn't in the page, the cursor would be moved to the top or bottom of the page (depending on search direction). This fixes that by only moving the page if the search term is actually in the current buffer.
Diffstat (limited to 'src/browsertab.cpp')
| -rw-r--r-- | src/browsertab.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/browsertab.cpp b/src/browsertab.cpp index 8cc30a8..c86051d 100644 --- a/src/browsertab.cpp +++ b/src/browsertab.cpp @@ -1628,7 +1628,8 @@ void BrowserTab::on_search_box_returnPressed() void BrowserTab::on_search_next_clicked() { - if (!this->ui->text_browser->find(this->ui->search_box->text())) + if (!this->ui->text_browser->find(this->ui->search_box->text()) && + this->current_buffer.contains(this->ui->search_box->text().toUtf8())) { // Wrap search this->ui->text_browser->moveCursor(QTextCursor::Start); @@ -1638,7 +1639,8 @@ void BrowserTab::on_search_next_clicked() void BrowserTab::on_search_previous_clicked() { - if (!this->ui->text_browser->find(this->ui->search_box->text(), QTextDocument::FindBackward)) + if (!this->ui->text_browser->find(this->ui->search_box->text(), QTextDocument::FindBackward) && + this->current_buffer.contains(this->ui->search_box->text().toUtf8())) { // Wrap search this->ui->text_browser->moveCursor(QTextCursor::End); |
