diff options
| author | weinan li <[email protected]> | 2025-09-03 14:06:16 +0000 |
|---|---|---|
| committer | Felix Ernst <[email protected]> | 2025-09-03 16:06:16 +0200 |
| commit | 655763fbc977cc900cc367f1797f752c7b217c71 (patch) | |
| tree | 72f925648008c91bd299726d2c0fea7ad1f20461 /src/search | |
| parent | 479ce3a1641398a8506812300834666614013850 (diff) | |
Search::Bar: Preserve cursor position
Prior to this commit editing the search term would sometimes change the
cursor position. This commit makes sure the cursor position does not
move by itself.
BUG: 507272
Diffstat (limited to 'src/search')
| -rw-r--r-- | src/search/bar.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/search/bar.cpp b/src/search/bar.cpp index 794274cef..01d8a1a5b 100644 --- a/src/search/bar.cpp +++ b/src/search/bar.cpp @@ -203,7 +203,9 @@ void Bar::setVisible(bool visible, Animated animated) void Bar::updateState(const std::shared_ptr<const DolphinQuery> &dolphinQuery) { + const int cursorPosition = m_searchTermEditor->cursorPosition(); m_searchTermEditor->setText(dolphinQuery->searchTerm()); + m_searchTermEditor->setCursorPosition(qMin(cursorPosition, dolphinQuery->searchTerm().length())); // When the Popup is closed users might not know whether they are searching in file names or contents. This can be problematic when users do not find a // file and then assume it doesn't exist. We consider searching for names matching the search term the default and only show a generic "Search…" text as // the placeholder then. But when names are not searched we change the placeholder message to make this clear. |
