Skip to content

Commit 04c96e4

Browse files
committed
Find/Replace overlay: fix content assist not available in Java files
Ctrl+Space in the overlay's search/replace fields never opened content assist in Java files because ContentAssistCommandAdapter activates its handler on the workbench-root IHandlerService without an expression, while the target editor keeps a part-scoped handler for the same command permanently active via ActivePartExpression. Since handler conflicts are resolved by evaluated source priority regardless of context nesting, the editor's higher-priority activation always wins, independent of where focus actually is. Fix this by registering an ordinary FindReplaceOverlayAction for the content-assist command, the same way EDIT_FIND_AND_REPLACE is already handled: activated through registerAction()'s overlayFocusedExpression, which alone already outranks the editor's ActivePartExpression-based activation regardless of which IHandlerService the activation lives on, so no separate, part-scoped override mechanism is needed for this. Fixes #2651
1 parent ce4e10f commit 04c96e4

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

  • bundles/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/findandreplace/overlay

bundles/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/findandreplace/overlay/FindReplaceOverlay.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,8 @@ private void createCloseTools() {
501501
// Also close on Ctrl+F: otherwise it would reopen (a duplicate of) this very overlay.
502502
commandSupport.registerAction(
503503
new FindReplaceOverlayAction(this::close, IWorkbenchCommandConstants.EDIT_FIND_AND_REPLACE));
504+
commandSupport.registerAction(new FindReplaceOverlayAction(this::triggerContentAssist,
505+
ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS));
504506

505507
// Close button
506508
new AccessibleToolItemBuilder(closeTools).withStyleBits(SWT.PUSH)
@@ -976,6 +978,14 @@ private void updateContentAssistAvailability() {
976978
setContentAssistsEnablement(findReplaceLogic.isAvailableAndActive(SearchOptions.REGEX));
977979
}
978980

981+
private void triggerContentAssist() {
982+
if (searchBar.isFocusControl() && contentAssistSearchField.isEnabled()) {
983+
contentAssistSearchField.openProposalPopup();
984+
} else if (okayToUse(replaceBar) && replaceBar.isFocusControl() && contentAssistReplaceField.isEnabled()) {
985+
contentAssistReplaceField.openProposalPopup();
986+
}
987+
}
988+
979989
private void decorate() {
980990
if (findReplaceLogic.isAvailableAndActive(SearchOptions.REGEX)) {
981991
SearchDecoration.validateRegex(getFindString(), searchBarDecoration);

0 commit comments

Comments
 (0)