Find/Replace Overlay: Restore cursor position when search input is cleared
Restores the editor caret to its original position when the Find/Replace overlay search field is cleared.
Fixes #1944
This PR introduces logic to restore the original caret/selection position when the search input field becomes empty, but only when incremental search mode is active. This ensures consistent and expected behavior for users typing in the Find/Replace overlay.
Key Changes
- Updated performSearch()
- Added a conditional check for SearchOptions.INCREMENTAL when the find string is empty.
- Calls restoreSelectionIfEmpty() to restore the selection only in incremental mode.
- Added restoreSelectionIfEmpty() method
- Restores the selection to incrementalBaseLocation if incremental mode is active and a valid base location exists.
- Skips restoration when incremental mode is not active to avoid unexpected behavior in non-incremental searches.
Accordingly the below test cases are updated/added.
- testResetIncrementalBaseLocation()
- testRestoreSelectionOnEmptyFindStringInIncrementalMode()
- testNoRestoreOnEmptyFindStringWhenNotIncremental()
- testSetFindString_incrementalActive()
@HeikoKlare : Can you have a look into this when you get some time please.
Test Results
3 018 files ±0 3 018 suites ±0 2h 9m 35s ⏱️ +57s 8 236 tests +2 7 987 ✅ +2 249 💤 ±0 0 ❌ ±0 23 628 runs +6 22 834 ✅ +6 794 💤 ±0 0 ❌ ±0
Results for commit 572c2ea6. ± Comparison against base commit bb70d779.
:recycle: This comment has been updated with latest results.
@deepika-u thank you for working on this!
We already have a bunch of tests for the
FindReplaceLogicas well as for the dialog and overlay UIs (inFindReplaceUITest). Could you please extend them with test methods to cover the use cases you address? That would help to verify the behavior (now and against regressions in the future), and it would also make it easier to understand how the additions are supposed to behave when one can just read the use cases in the form of tests.
Let me check on them and also test failures. Thanks for your time.
@HeikoKlare As suggested added and updated junit test cases for the same. Have a look when you get some time please.
Sorry, i couldnt reply on your comments as i had some workspace issues. Now all set, will check and reply on this.
@HeikoKlare Can you recheck now when you get some time please? Mac failures are unrelated as i have seen. Thanks alot for your time.
Mac failures cleared now. But seeing this issue now "05:42:31.581 [ERROR] Failed to execute goal org.eclipse.tycho:tycho-source-plugin:5.0.1-SNAPSHOT:plugin-source (plugin-source) on project org.eclipse.ui.workbench: Error creating source archive: Problem creating jar: Execution exception: Java heap space -> [Help 1]
05:42:31.581 [ERROR] ". @HeikoKlare - Thanks alot for your time.
So I propose to try to completely remove the new base location and only use the incremental base position to restore to when clearing the input field. In addition, this should only be done incremental mode is active (or at least no unexpected behavior should occur in case incremental mode is deactivated).
Hi Heiko, I have tried checking further on your inputs, updated the changes accordingly. Can you take a look when you get some time please?
@HeikoKlare Sorry to bother you again, can you take a look at it when you get some time please?
I will have a look as soon as I find the time. In my opinion, it should wait for the next release cycle anyway since the fix is not urgently needed but affects a central UI/UX-related element with potentially unforseeable side effects. That's why I have to consider it with low priority as long as we have things for the upcoming release to do.
Appreciate the heads-up. I’ll proceed with low-impact investigation and stay aligned with your timeline.
I really like the current proposal. The logic is greatly simple and straightforward now. At least for me, the behavior also fits to what I as a user would expect. Thank you also for updating the tests again.
I only have minor comments left. Then I would consider this ready to be merged right after master opens for the next release cycle.
Thanks alot once again for your time. All the changes are done now. Commits are squashed.
This pull request changes some projects for the first time in this development cycle. Therefore the following files need a version increment:
bundles/org.eclipse.ui.workbench.texteditor/META-INF/MANIFEST.MF
tests/org.eclipse.ui.workbench.texteditor.tests/META-INF/MANIFEST.MF
An additional commit containing all the necessary changes was pushed to the top of this PR's branch. To obtain these changes (for example if you want to push more changes) either fetch from your fork or apply the git patch.
Git patch
From f117f0d104891e5e2f28cda4609fef3258d06985 Mon Sep 17 00:00:00 2001
From: Eclipse Platform Bot <[email protected]>
Date: Mon, 1 Dec 2025 05:59:49 +0000
Subject: [PATCH] Version bump(s) for 4.39 stream
diff --git a/bundles/org.eclipse.ui.workbench.texteditor/META-INF/MANIFEST.MF b/bundles/org.eclipse.ui.workbench.texteditor/META-INF/MANIFEST.MF
index 192dae4485..bb3e458534 100644
--- a/bundles/org.eclipse.ui.workbench.texteditor/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.ui.workbench.texteditor/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.ui.workbench.texteditor; singleton:=true
-Bundle-Version: 3.19.400.qualifier
+Bundle-Version: 3.19.500.qualifier
Bundle-Activator: org.eclipse.ui.internal.texteditor.TextEditorPlugin
Bundle-ActivationPolicy: lazy
Bundle-Vendor: %providerName
diff --git a/tests/org.eclipse.ui.workbench.texteditor.tests/META-INF/MANIFEST.MF b/tests/org.eclipse.ui.workbench.texteditor.tests/META-INF/MANIFEST.MF
index bbf10b57c2..8995cf04ca 100644
--- a/tests/org.eclipse.ui.workbench.texteditor.tests/META-INF/MANIFEST.MF
+++ b/tests/org.eclipse.ui.workbench.texteditor.tests/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %Plugin.name
Bundle-SymbolicName: org.eclipse.ui.workbench.texteditor.tests
-Bundle-Version: 3.14.1000.qualifier
+Bundle-Version: 3.14.1100.qualifier
Bundle-Vendor: %Plugin.providerName
Bundle-Localization: plugin
Export-Package:
--
2.51.2
Further information are available in Common Build Issues - Missing version increments.
Thanks alot.