From 655763fbc977cc900cc367f1797f752c7b217c71 Mon Sep 17 00:00:00 2001 From: weinan li Date: Wed, 3 Sep 2025 14:06:16 +0000 Subject: 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 --- src/search/bar.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/search/bar.cpp') 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 &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. -- cgit v1.3