Skip to content

Make "Compare with Clipboard" work in active editor of FormEditor #2100

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.forms.editor.FormEditor;
import org.eclipse.ui.texteditor.ITextEditor;

public class ClipboardCompare extends BaseCompareAction implements IObjectActionDelegate {
Expand Down Expand Up @@ -88,6 +89,9 @@ private void processComparison(IFile file, Shell parentShell) throws IOException
return;
}
final String selectionContents;
if (editor instanceof FormEditor fromEditor) {
editor = fromEditor.getActiveEditor();
}
if (editor instanceof ITextEditor txtEditor) {
ISelection selection = txtEditor.getSelectionProvider().getSelection();
if (selection instanceof ITextSelection textSelection) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.forms.editor.FormEditor;
import org.eclipse.ui.texteditor.ITextEditor;

public class ClipboardReplace extends BaseCompareAction {
Expand All @@ -42,6 +43,9 @@ protected void run(ISelection selection) {
try {
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
IEditorPart editor = page.getActiveEditor();
if (editor instanceof FormEditor fromEditor) {
editor = fromEditor.getActiveEditor();
}
IEditorInput input = editor.getEditorInput();
if (input instanceof IFileEditorInput ed) {
IFile file2 = ed.getFile();
Expand Down
Loading