Skip to content

Conversation

@HeikoKlare
Copy link
Contributor

@HeikoKlare HeikoKlare commented Jan 2, 2025

Currently, the FindReplaceLogic disables the incremental mode (i.e., search-as-you-type) in case the regex search option is activated. This makes the FindReplaceOverlay, which uses search-as-you-type in all other situations, behave non-intuitively when the regex option is activated.

In order to achieve consistent, user-expectable behavior of the find and replace functionality and because of lacking arguments against using search-as-you-type in regex mode, this change makes the regex search mode independent from the incremental mode of the FindReplaceLogic. In consequence, the FindReplaceOverlay always uses search-as-you-type, no matter which search options are activated.
In addition, explicit test code for that exceptional behavior is removed or adapted.

Contributes to #2066

Contributes to #2646

Fixes #1911

Note that this also aligns the behavior with similar functionality in other tools (like VS code).

@eclipse-platform-bot
Copy link
Contributor

eclipse-platform-bot commented Jan 2, 2025

This pull request changes some projects for the first time in this development cycle.
Therefore the following files need a version increment:

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 1601ec1facdeac0f314410692da500461d40f833 Mon Sep 17 00:00:00 2001
From: Eclipse Platform Bot <[email protected]>
Date: Thu, 2 Jan 2025 21:49:24 +0000
Subject: [PATCH] Version bump(s) for 4.35 stream


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 1a6ef95d92..05ec3b3086 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.600.qualifier
+Bundle-Version: 3.14.700.qualifier
 Bundle-Vendor: %Plugin.providerName
 Bundle-Localization: plugin
 Export-Package: 
-- 
2.47.1

Further information are available in Common Build Issues - Missing version increments.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 2, 2025

Test Results

 1 821 files  ±0   1 821 suites  ±0   1h 27m 19s ⏱️ - 1m 45s
 7 738 tests ±0   7 510 ✅ ±0  228 💤 ±0  0 ❌ ±0 
24 375 runs  ±0  23 626 ✅ ±0  749 💤 ±0  0 ❌ ±0 

Results for commit 8bd6fc0. ± Comparison against base commit 36c6b93.

This pull request removes 1 and adds 1 tests. Note that renamed tests count towards both.
org.eclipse.ui.workbench.texteditor.tests.FindReplaceDialogTest ‑ testIncrementalSearchOnlyEnabledWhenAllowed
org.eclipse.ui.workbench.texteditor.tests.FindReplaceDialogTest ‑ testRegExSearch_nonIncremental

♻️ This comment has been updated with latest results.

@HeikoKlare HeikoKlare force-pushed the findreplace-incremental-with-regex branch from 2970bb6 to 020d00d Compare January 2, 2025 21:44
@HeikoKlare HeikoKlare changed the title FindReplaceOverlay: use search-as-you-type in regex mode FindReplaceOverlay: use search-as-you-type in regex mode #1911 Jan 2, 2025
@HeikoKlare HeikoKlare marked this pull request as ready for review January 3, 2025 06:58
@HeikoKlare
Copy link
Contributor Author

@jukzi may I ask you to test whether this change fixes the behavior/issue you reported in #2066 (comment) for performing text replacements in regex mode?

@merks
Copy link
Contributor

merks commented Jan 3, 2025

I was reading this yesterday and I wondered if this is really such a great idea. With more complex regular expressions you often end up in an intermediate state with syntax errors. Moreover if I type a and then continue typing to a|b, what happens if there is a b before an a from the point at which I started? So I tested that and it appears to work as one would hope, i.e., doing nothing when there is a syntax error and backing up to an earlier match if there is one. So that appears to be goodness...

@jukzi
Copy link
Contributor

jukzi commented Jan 3, 2025

Too much magic is also unintuitive. Disabling search-as-you-type for regexp may be unwanted magic (especially if the search string is a plain text). Not searching for invalid regexp is expectable. reverting to a previous position would probably too much magic, the use can still manually repositon manually.

I tested this PR with:

package a;

public class A {
public static void main(String[] args) {
	
}
public static void main2(String[] args) {
	
}
public static void main3(String[] args) {
	
}
}

Still it does not work to search "main" (+ explicitly using search forward) and then replacing with main\n then main\n\r or main\r\n:
image
Still totally unintuitive that replacing with main\r\n right from start does work.

@HeikoKlare
Copy link
Contributor Author

With more complex regular expressions you often end up in an intermediate state with syntax errors.

Yes, that's definitely a drawback I see as well. The current search match may be "jumping around" while you try to correct your expression. On the other hand, the benefit of this is that you directly see where a regex matches while typing, so you have an "example match" that directly allows you to have some validation of correctness of your expression. Note that other tools / IDEs (VS Code, IntelliJ) work like this as well: they have search-as-you-type always enabled, even in regex mode. I would currently expect the benefits for the user (consistent behavior, direct feedback) and developer (reduced complexity) to outweigh potential drawbacks or "needs to adapt" to the changed behavior.

Moreover if I type a and then continue typing to a|b, what happens if there is a b before an a from the point at which I started? So I tested that and it appears to work as one would hope, i.e., doing nothing when there is a syntax error and backing up to an earlier match if there is one.

For anyone interested, here is a video capturing the behavior:
findreplace_regex_incremental

Still totally unintuitive that replacing with main\r\n right from start does work.

Why is that "totally unintuitive"? I would say that's exactly the expected behavior.

Still it does not work to search "main" (+ explicitly using search forward) and then replacing with main\n then main\n\r or main\r\n:

Well, this is mixing up different things. Replacing with \n\ or \n\r will not work because they are invalid delimiters on Windows, so it's expected that neither of them works (like it has always been), no matter in which order you try to perform them. What currently seems to be missing is proper information about the failed replacement in the status bar, but that's an additional bug for which we may file another issue.
What I agree that should work (and currently does not) is that if you try to replace with some faulty regex (like main\n), then correct that one (e.g., to main\r\n) and then perform a replace again. Probably that's the scenario you initially referred to but from the description that was unfortunately not clear to me. We should then file a dedicated issue for that bug as, if I am not mistaken, that is not covered by any of the existing issues yet. And I would propose keep that one independent from this PR as well.

@jukzi
Copy link
Contributor

jukzi commented Jan 3, 2025

testing this PR i found this Error in my Log:

java.lang.reflect.InvocationTargetException
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:115)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at org.eclipse.ui.internal.findandreplace.overlay.FindReplaceOverlay$1.setTextEditorActionsActivated(FindReplaceOverlay.java:189)
	at org.eclipse.ui.internal.findandreplace.overlay.FindReplaceOverlay$1.focusLost(FindReplaceOverlay.java:166)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:181)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:91)
	at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4311)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1208)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1232)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1213)
	at org.eclipse.swt.widgets.Control.sendFocusEvent(Control.java:2906)
	at org.eclipse.swt.widgets.Widget.wmKillFocus(Widget.java:2054)
	at org.eclipse.swt.widgets.Control.WM_KILLFOCUS(Control.java:5210)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:4797)
	at org.eclipse.swt.widgets.Text.windowProc(Text.java:2655)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:5079)
	at org.eclipse.swt.internal.win32.OS.SetFocus(Native Method)
	at org.eclipse.swt.widgets.Control.forceFocus(Control.java:1054)
	at org.eclipse.swt.widgets.Control.setFocus(Control.java:3408)
	at org.eclipse.swt.widgets.Composite.setFocus(Composite.java:1089)
	at org.eclipse.swt.widgets.Composite.setFocus(Composite.java:1087)
	at org.eclipse.swt.custom.CTabFolder.setFocus(CTabFolder.java:2696)
	at org.eclipse.swt.widgets.Control.fixFocus(Control.java:1011)
	at org.eclipse.swt.widgets.Control.setVisible(Control.java:3961)
	at org.eclipse.swt.custom.CTabFolder.destroyItem(CTabFolder.java:789)
	at org.eclipse.swt.custom.CTabItem.dispose(CTabItem.java:132)
	at org.eclipse.e4.ui.workbench.renderers.swt.StackRenderer.hideChild(StackRenderer.java:1093)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeRemoveGui(PartRenderingEngine.java:872)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$4.run(PartRenderingEngine.java:857)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:47)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.removeGui(PartRenderingEngine.java:841)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeRemoveGui(PartRenderingEngine.java:896)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$4.run(PartRenderingEngine.java:857)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:47)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.removeGui(PartRenderingEngine.java:841)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeRemoveGui(PartRenderingEngine.java:896)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$4.run(PartRenderingEngine.java:857)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:47)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.removeGui(PartRenderingEngine.java:841)
	at org.eclipse.e4.ui.workbench.renderers.swt.ElementReferenceRenderer.disposeWidget(ElementReferenceRenderer.java:113)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeRemoveGui(PartRenderingEngine.java:934)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$4.run(PartRenderingEngine.java:857)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:47)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.removeGui(PartRenderingEngine.java:841)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeRemoveGui(PartRenderingEngine.java:896)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$4.run(PartRenderingEngine.java:857)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:47)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.removeGui(PartRenderingEngine.java:841)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeRemoveGui(PartRenderingEngine.java:896)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$4.run(PartRenderingEngine.java:857)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:47)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.removeGui(PartRenderingEngine.java:841)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeRemoveGui(PartRenderingEngine.java:896)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$4.run(PartRenderingEngine.java:857)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:47)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.removeGui(PartRenderingEngine.java:841)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeRemoveGui(PartRenderingEngine.java:896)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$4.run(PartRenderingEngine.java:857)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:47)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.removeGui(PartRenderingEngine.java:841)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeRemoveGui(PartRenderingEngine.java:896)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$4.run(PartRenderingEngine.java:857)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:47)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.removeGui(PartRenderingEngine.java:841)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeRemoveGui(PartRenderingEngine.java:896)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$4.run(PartRenderingEngine.java:857)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:47)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.removeGui(PartRenderingEngine.java:841)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeRemoveGui(PartRenderingEngine.java:896)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$4.run(PartRenderingEngine.java:857)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:47)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.removeGui(PartRenderingEngine.java:841)
	at org.eclipse.ui.internal.WorkbenchWindow.hardClose(WorkbenchWindow.java:2082)
	at org.eclipse.ui.internal.WorkbenchWindow.busyClose(WorkbenchWindow.java:1723)
	at org.eclipse.ui.internal.WorkbenchWindow.lambda$5(WorkbenchWindow.java:1747)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:67)
	at org.eclipse.ui.internal.WorkbenchWindow.close(WorkbenchWindow.java:1747)
	at org.eclipse.ui.internal.Workbench$11.run(Workbench.java:1157)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:47)
	at org.eclipse.ui.internal.Workbench.busyClose(Workbench.java:1140)
	at org.eclipse.ui.internal.Workbench.lambda$4(Workbench.java:1446)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:67)
	at org.eclipse.ui.internal.Workbench.close(Workbench.java:1446)
	at org.eclipse.ui.internal.Workbench.close(Workbench.java:1417)
	at org.eclipse.ui.internal.WorkbenchWindow.busyClose(WorkbenchWindow.java:1720)
	at org.eclipse.ui.internal.WorkbenchWindow.lambda$5(WorkbenchWindow.java:1747)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:67)
	at org.eclipse.ui.internal.WorkbenchWindow.close(WorkbenchWindow.java:1747)
	at org.eclipse.ui.internal.WorkbenchWindow.close(WorkbenchWindow.java:1756)
	at org.eclipse.ui.internal.WorkbenchWindow.lambda$2(WorkbenchWindow.java:505)
	at org.eclipse.e4.ui.workbench.renderers.swt.WBWRenderer.lambda$4(WBWRenderer.java:574)
	at org.eclipse.swt.events.ShellListener$2.shellClosed(ShellListener.java:101)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:136)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:91)
	at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4311)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1208)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1232)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1217)
	at org.eclipse.swt.widgets.Decorations.closeWidget(Decorations.java:273)
	at org.eclipse.swt.widgets.Decorations.WM_CLOSE(Decorations.java:1554)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:4765)
	at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:342)
	at org.eclipse.swt.widgets.Decorations.windowProc(Decorations.java:1482)
	at org.eclipse.swt.widgets.Shell.windowProc(Shell.java:2349)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:5079)
	at org.eclipse.swt.internal.win32.OS.DefWindowProc(Native Method)
	at org.eclipse.swt.widgets.Shell.callWindowProc(Shell.java:512)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:4865)
	at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:342)
	at org.eclipse.swt.widgets.Decorations.windowProc(Decorations.java:1482)
	at org.eclipse.swt.widgets.Shell.windowProc(Shell.java:2349)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:5079)
	at org.eclipse.swt.internal.win32.OS.DefWindowProc(Native Method)
	at org.eclipse.swt.widgets.Shell.callWindowProc(Shell.java:512)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:4865)
	at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:342)
	at org.eclipse.swt.widgets.Decorations.windowProc(Decorations.java:1482)
	at org.eclipse.swt.widgets.Shell.windowProc(Shell.java:2349)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:5079)
	at org.eclipse.swt.internal.win32.OS.DispatchMessage(Native Method)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3695)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1151)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:339)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1042)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:153)
	at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:663)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:339)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:570)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:173)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:178)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:208)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:143)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:109)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:439)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:271)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:668)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:605)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1481)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1454)
Caused by: java.lang.NullPointerException: Cannot invoke "org.eclipse.e4.core.contexts.IEclipseContext.get(java.lang.Class)" because "context" is null
	at org.eclipse.ui.internal.handlers.LegacyHandlerService.registerLegacyHandler(LegacyHandlerService.java:162)
	at org.eclipse.ui.internal.handlers.LegacyHandlerService.registerLegacyHandler(LegacyHandlerService.java:156)
	at org.eclipse.ui.internal.handlers.LegacyHandlerService.activateHandler(LegacyHandlerService.java:302)
	at org.eclipse.ui.internal.handlers.LegacyHandlerService.activateHandler(LegacyHandlerService.java:295)
	at org.eclipse.ui.SubActionBars.setGlobalActionHandler(SubActionBars.java:549)
	at org.eclipse.ui.texteditor.BasicTextEditorActionContributor.doSetActiveEditor(BasicTextEditorActionContributor.java:220)
	at org.eclipse.ui.texteditor.BasicTextEditorActionContributor.setActiveEditor(BasicTextEditorActionContributor.java:255)
	at org.eclipse.jdt.internal.ui.javaeditor.BasicJavaEditorActionContributor.setActiveEditor(BasicJavaEditorActionContributor.java:181)
	at org.eclipse.jdt.internal.ui.javaeditor.BasicCompilationUnitEditorActionContributor.setActiveEditor(BasicCompilationUnitEditorActionContributor.java:148)
	at org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditorActionContributor.setActiveEditor(CompilationUnitEditorActionContributor.java:65)
	at org.eclipse.ui.texteditor.AbstractTextEditor.setActionActivation(AbstractTextEditor.java:5233)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
	... 140 more
Root exception:
java.lang.NullPointerException: Cannot invoke "org.eclipse.e4.core.contexts.IEclipseContext.get(java.lang.Class)" because "context" is null
	at org.eclipse.ui.internal.handlers.LegacyHandlerService.registerLegacyHandler(LegacyHandlerService.java:162)
	at org.eclipse.ui.internal.handlers.LegacyHandlerService.registerLegacyHandler(LegacyHandlerService.java:156)
	at org.eclipse.ui.internal.handlers.LegacyHandlerService.activateHandler(LegacyHandlerService.java:302)
	at org.eclipse.ui.internal.handlers.LegacyHandlerService.activateHandler(LegacyHandlerService.java:295)
	at org.eclipse.ui.SubActionBars.setGlobalActionHandler(SubActionBars.java:549)
	at org.eclipse.ui.texteditor.BasicTextEditorActionContributor.doSetActiveEditor(BasicTextEditorActionContributor.java:220)
	at org.eclipse.ui.texteditor.BasicTextEditorActionContributor.setActiveEditor(BasicTextEditorActionContributor.java:255)
	at org.eclipse.jdt.internal.ui.javaeditor.BasicJavaEditorActionContributor.setActiveEditor(BasicJavaEditorActionContributor.java:181)
	at org.eclipse.jdt.internal.ui.javaeditor.BasicCompilationUnitEditorActionContributor.setActiveEditor(BasicCompilationUnitEditorActionContributor.java:148)
	at org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditorActionContributor.setActiveEditor(CompilationUnitEditorActionContributor.java:65)
	at org.eclipse.ui.texteditor.AbstractTextEditor.setActionActivation(AbstractTextEditor.java:5233)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at org.eclipse.ui.internal.findandreplace.overlay.FindReplaceOverlay$1.setTextEditorActionsActivated(FindReplaceOverlay.java:189)
	at org.eclipse.ui.internal.findandreplace.overlay.FindReplaceOverlay$1.focusLost(FindReplaceOverlay.java:166)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:181)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:91)
	at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4311)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1208)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1232)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1213)
	at org.eclipse.swt.widgets.Control.sendFocusEvent(Control.java:2906)
	at org.eclipse.swt.widgets.Widget.wmKillFocus(Widget.java:2054)
	at org.eclipse.swt.widgets.Control.WM_KILLFOCUS(Control.java:5210)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:4797)
	at org.eclipse.swt.widgets.Text.windowProc(Text.java:2655)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:5079)
	at org.eclipse.swt.internal.win32.OS.SetFocus(Native Method)
	at org.eclipse.swt.widgets.Control.forceFocus(Control.java:1054)
	at org.eclipse.swt.widgets.Control.setFocus(Control.java:3408)
	at org.eclipse.swt.widgets.Composite.setFocus(Composite.java:1089)
	at org.eclipse.swt.widgets.Composite.setFocus(Composite.java:1087)
	at org.eclipse.swt.custom.CTabFolder.setFocus(CTabFolder.java:2696)
	at org.eclipse.swt.widgets.Control.fixFocus(Control.java:1011)
	at org.eclipse.swt.widgets.Control.setVisible(Control.java:3961)
	at org.eclipse.swt.custom.CTabFolder.destroyItem(CTabFolder.java:789)
	at org.eclipse.swt.custom.CTabItem.dispose(CTabItem.java:132)
	at org.eclipse.e4.ui.workbench.renderers.swt.StackRenderer.hideChild(StackRenderer.java:1093)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeRemoveGui(PartRenderingEngine.java:872)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$4.run(PartRenderingEngine.java:857)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:47)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.removeGui(PartRenderingEngine.java:841)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeRemoveGui(PartRenderingEngine.java:896)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$4.run(PartRenderingEngine.java:857)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:47)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.removeGui(PartRenderingEngine.java:841)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeRemoveGui(PartRenderingEngine.java:896)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$4.run(PartRenderingEngine.java:857)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:47)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.removeGui(PartRenderingEngine.java:841)
	at org.eclipse.e4.ui.workbench.renderers.swt.ElementReferenceRenderer.disposeWidget(ElementReferenceRenderer.java:113)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeRemoveGui(PartRenderingEngine.java:934)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$4.run(PartRenderingEngine.java:857)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:47)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.removeGui(PartRenderingEngine.java:841)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeRemoveGui(PartRenderingEngine.java:896)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$4.run(PartRenderingEngine.java:857)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:47)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.removeGui(PartRenderingEngine.java:841)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeRemoveGui(PartRenderingEngine.java:896)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$4.run(PartRenderingEngine.java:857)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:47)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.removeGui(PartRenderingEngine.java:841)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeRemoveGui(PartRenderingEngine.java:896)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$4.run(PartRenderingEngine.java:857)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:47)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.removeGui(PartRenderingEngine.java:841)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeRemoveGui(PartRenderingEngine.java:896)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$4.run(PartRenderingEngine.java:857)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:47)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.removeGui(PartRenderingEngine.java:841)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeRemoveGui(PartRenderingEngine.java:896)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$4.run(PartRenderingEngine.java:857)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:47)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.removeGui(PartRenderingEngine.java:841)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeRemoveGui(PartRenderingEngine.java:896)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$4.run(PartRenderingEngine.java:857)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:47)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.removeGui(PartRenderingEngine.java:841)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeRemoveGui(PartRenderingEngine.java:896)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$4.run(PartRenderingEngine.java:857)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:47)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.removeGui(PartRenderingEngine.java:841)
	at org.eclipse.ui.internal.WorkbenchWindow.hardClose(WorkbenchWindow.java:2082)
	at org.eclipse.ui.internal.WorkbenchWindow.busyClose(WorkbenchWindow.java:1723)
	at org.eclipse.ui.internal.WorkbenchWindow.lambda$5(WorkbenchWindow.java:1747)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:67)
	at org.eclipse.ui.internal.WorkbenchWindow.close(WorkbenchWindow.java:1747)
	at org.eclipse.ui.internal.Workbench$11.run(Workbench.java:1157)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:47)
	at org.eclipse.ui.internal.Workbench.busyClose(Workbench.java:1140)
	at org.eclipse.ui.internal.Workbench.lambda$4(Workbench.java:1446)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:67)
	at org.eclipse.ui.internal.Workbench.close(Workbench.java:1446)
	at org.eclipse.ui.internal.Workbench.close(Workbench.java:1417)
	at org.eclipse.ui.internal.WorkbenchWindow.busyClose(WorkbenchWindow.java:1720)
	at org.eclipse.ui.internal.WorkbenchWindow.lambda$5(WorkbenchWindow.java:1747)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:67)
	at org.eclipse.ui.internal.WorkbenchWindow.close(WorkbenchWindow.java:1747)
	at org.eclipse.ui.internal.WorkbenchWindow.close(WorkbenchWindow.java:1756)
	at org.eclipse.ui.internal.WorkbenchWindow.lambda$2(WorkbenchWindow.java:505)
	at org.eclipse.e4.ui.workbench.renderers.swt.WBWRenderer.lambda$4(WBWRenderer.java:574)
	at org.eclipse.swt.events.ShellListener$2.shellClosed(ShellListener.java:101)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:136)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:91)
	at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4311)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1208)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1232)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1217)
	at org.eclipse.swt.widgets.Decorations.closeWidget(Decorations.java:273)
	at org.eclipse.swt.widgets.Decorations.WM_CLOSE(Decorations.java:1554)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:4765)
	at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:342)
	at org.eclipse.swt.widgets.Decorations.windowProc(Decorations.java:1482)
	at org.eclipse.swt.widgets.Shell.windowProc(Shell.java:2349)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:5079)
	at org.eclipse.swt.internal.win32.OS.DefWindowProc(Native Method)
	at org.eclipse.swt.widgets.Shell.callWindowProc(Shell.java:512)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:4865)
	at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:342)
	at org.eclipse.swt.widgets.Decorations.windowProc(Decorations.java:1482)
	at org.eclipse.swt.widgets.Shell.windowProc(Shell.java:2349)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:5079)
	at org.eclipse.swt.internal.win32.OS.DefWindowProc(Native Method)
	at org.eclipse.swt.widgets.Shell.callWindowProc(Shell.java:512)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:4865)
	at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:342)
	at org.eclipse.swt.widgets.Decorations.windowProc(Decorations.java:1482)
	at org.eclipse.swt.widgets.Shell.windowProc(Shell.java:2349)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:5079)
	at org.eclipse.swt.internal.win32.OS.DispatchMessage(Native Method)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3695)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1151)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:339)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1042)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:153)
	at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:663)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:339)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:570)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:173)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:178)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:208)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:143)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:109)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:439)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:271)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:668)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:605)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1481)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1454)

@jukzi
Copy link
Contributor

jukzi commented Jan 3, 2025

beside the error i think it's intuitive to have search as you type enabled for regexp as provided by this PR.

@HeikoKlare
Copy link
Contributor Author

Thank you! The error is unrelated to this PR. I have never seen it before but it is related to disablement/enablement of key bindings for the FindReplaceOverlay. At first impression, it rather seems to be some issue in the according functionality of the text editor, but since that one is not "official" API and only used via reflection (just like the breadcrumb does it), there is of course no guarantee to work under every condition. Definitely something to take a look into.

If no one objects to the PR itself (enabling search-as-you-type for regex mode), I would like to give it a try next week. I will then address this as a follow-up:

@HeikoKlare
Copy link
Contributor Author

Thank you again for reporting the error, Jörg! I can reproduce it and have created a dedicated issue for it as it is unrelated to this PR:

I have created a separate PR proposing a fix for it.

…form#1911

Currently, the FindReplaceLogic disables the incremental mode (i.e.,
search-as-you-type) in case the regex search option is activated. This
makes the FindReplaceOverlay, which uses search-as-you-type in all other
situations, behave non-intuitively when the regex option is activated.

In order to achieve consistent, user-expectable behavior of the find and
replace functionality and because of lacking arguments against using
search-as-you-type in regex mode, this change makes the regex search
mode independent from the incremental mode of the FindReplaceLogic. In
consequence, the FindReplaceOverlay always uses search-as-you-type, no
matter which search options are activated.
In addition, explicit test code for that exceptional behavior is removed
or adapted.

Contributes to
eclipse-platform#2066

Contributes to
eclipse-platform#2646

Fixes eclipse-platform#1911
@HeikoKlare HeikoKlare force-pushed the findreplace-incremental-with-regex branch from af5f0db to 8bd6fc0 Compare January 7, 2025 16:10
@HeikoKlare HeikoKlare merged commit 58bb65c into eclipse-platform:master Jan 7, 2025
17 checks passed
@HeikoKlare HeikoKlare deleted the findreplace-incremental-with-regex branch January 7, 2025 16:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[find/replace overlay] it is not intuitive that enabling RegEx disables Incremental Search

4 participants