Skip to content

Conversation

@SougandhS
Copy link
Contributor

@SougandhS SougandhS commented May 8, 2025

This feature will allow users to compare either the selected text or the entire editor content against the current clipboard contents similar to other IDEs.


image


If users want to just compare just a selection in an editor, select the section and choose Compare with-> Clipboard
(I had changes copied..)

Selection.mp4

Selection2.mp4

If User want to compare entire Editor, either select all or select None and choose _Compare with-> Clipboard_
Entire.mp4

@github-actions
Copy link
Contributor

github-actions bot commented May 8, 2025

Test Results

 1 947 files  ±0   1 947 suites  ±0   1h 29m 41s ⏱️ - 6m 3s
 4 717 tests ±0   4 693 ✅ ±0   24 💤 ±0  0 ❌ ±0 
14 151 runs  ±0  13 984 ✅ ±0  167 💤 ±0  0 ❌ ±0 

Results for commit e8d0937. ± Comparison against base commit 1ef11c0.

♻️ This comment has been updated with latest results.

@SougandhS
Copy link
Contributor Author

Hi @iloveeclipse
Could you please check this when you have some time ?

@iloveeclipse
Copy link
Member

I'm biased here, since this feature is provided by AnyEdit Tools plugin since years:
https://marketplace.eclipse.org/content/anyedit-tools

@SougandhS
Copy link
Contributor Author

I'm biased here, since this feature is provided by AnyEdit Tools plugin since years: https://marketplace.eclipse.org/content/anyedit-tools

but having it built directly into Eclipse makes it easier and more consistent for users—no need to install or manage extra plugins just to do something that feels like it should be built-in

@vogella
Copy link
Contributor

vogella commented May 12, 2025

In my testing this does not reliable work.

For example in copy f.application from this file:

image

Now I select a java file and select Compare With -> Clipboard nothing happens.

image

@iloveeclipse
Copy link
Member

Why not let this feature be in AnyEdit plugin? It's tested, has more features etc.

@vogella
Copy link
Contributor

vogella commented May 12, 2025

Why not let this feature be in AnyEdit plugin? It's tested, has more features etc.

Having it in standard is desired for such a useful and core feature. Also I don't think every user has AnyEdit installed, for example I think I never did install it.

@iloveeclipse
Copy link
Member

I would expect then that this contribution would add same functionality AnyEdit provides for clipboard, means also context menus for files in Package Explorer, not just "Compare with..." but also "Replace with.." etc.

@SougandhS SougandhS force-pushed the CmpreSelcWithClip branch from bca7d6d to 0a132e9 Compare May 12, 2025 12:27
@SougandhS
Copy link
Contributor Author

In my testing this does not reliable work.
For example in copy f.application from this file:

This is fixed now

@SougandhS
Copy link
Contributor Author

I would expect then that this contribution would add same functionality AnyEdit provides for clipboard, means also context menus for files in Package Explorer, not just "Compare with..." but also "Replace with.." etc.

Sure. i'll add Replace with clipboard feature too 👍

@vogella
Copy link
Contributor

vogella commented May 12, 2025

I would expect then that this contribution would add same functionality AnyEdit provides for clipboard, means also context menus for files in Package Explorer, not just "Compare with..." but also "Replace with.." etc.

Sure. i'll add Replace with clipboard feature too 👍

Thanks. Next issue I see, is that it seems that I can also do this compare once. I tested my scenario above. After that I copied some source code from the compare editor and did the compare on another file. Nothing happens.

image

@SougandhS SougandhS force-pushed the CmpreSelcWithClip branch from 0a132e9 to 0096bed Compare May 13, 2025 11:17
@SougandhS
Copy link
Contributor Author

Next issue I see, is that it seems that I can also do this compare once. I tested my scenario above. After that I copied some source code from the compare editor and did the compare on another file. Nothing happens.

This is fixed now + Added replace with clipboard functionality + Compare/Replace from Project/Package exp context menu

Replace_1.mp4
Replace_2.mp4

@SougandhS SougandhS changed the title Compare selection or editor with clipboard Compare/Replace selection or editor with clipboard May 13, 2025
@vogella
Copy link
Contributor

vogella commented May 13, 2025

Calling compare on some files switching the project results in the following exception for me:

java.lang.NullPointerException: Cannot invoke "String.getBytes(java.nio.charset.Charset)" because "this.content" is null
at org.eclipse.compare.internal.ClipboardCompare$1ClipboardTypedElement.getContents(ClipboardCompare.java:148)
at org.eclipse.compare.internal.CompareUIPlugin.getContentType(CompareUIPlugin.java:1227)
at org.eclipse.compare.internal.CompareUIPlugin.getCommonType(CompareUIPlugin.java:1280)
at org.eclipse.compare.internal.CompareUIPlugin.findStructureViewerDescriptor(CompareUIPlugin.java:824)
at org.eclipse.compare.internal.CompareUIPlugin.findStructureViewer(CompareUIPlugin.java:867)
at org.eclipse.compare.CompareUI.findStructureViewer(CompareUI.java:321)
at org.eclipse.compare.CompareEditorInput.findStructureViewer(CompareEditorInput.java:893)
at org.eclipse.compare.internal.CompareStructureViewerSwitchingPane.getViewer(CompareStructureViewerSwitchingPane.java:87)
at org.eclipse.compare.CompareEditorInput$2.getViewer(CompareEditorInput.java:684)
at org.eclipse.compare.CompareViewerSwitchingPane.setInput(CompareViewerSwitchingPane.java:258)
at org.eclipse.compare.internal.CompareStructureViewerSwitchingPane.setInput(CompareStructureViewerSwitchingPane.java:140)
at org.eclipse.compare.CompareEditorInput.feedInput(CompareEditorInput.java:716)
at org.eclipse.compare.CompareEditorInput.createContents(CompareEditorInput.java:543)
at org.eclipse.compare.internal.CompareEditor.createCompareControl(CompareEditor.java:448)
at org.eclipse.compare.internal.CompareEditor.createPartControl(CompareEditor.java:400)
at org.eclipse.ui.internal.e4.compatibility.CompatibilityPart.createPartControl(CompatibilityPart.java:160)
at org.eclipse.ui.internal.e4.compatibility.CompatibilityEditor.createPartControl(CompatibilityEditor.java:96)
at org.eclipse.ui.internal.e4.compatibility.CompatibilityPart.create(CompatibilityPart.java:367)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
at java.base/java.lang.reflect.Method.invoke(Method.java:580)

@SougandhS
Copy link
Contributor Author

Calling compare on some files switching the project results in the following exception for me:

java.lang.NullPointerException: Cannot invoke "String.getBytes(java.nio.charset.Charset)" because "this.content" is null at org.eclipse.compare.internal.ClipboardCompare$1ClipboardTypedElement.getContents(ClipboardCompare.java:148) at org.eclipse.compare.internal.CompareUIPlugin.getContentType(CompareUIPlugin.java:1227) at org.eclipse.compare.internal.CompareUIPlugin.getCommonType(CompareUIPlugin.java:1280) at org.eclipse.compare.internal.CompareUIPlugin.findStructureViewerDescriptor(CompareUIPlugin.java:824) at org.eclipse.compare.internal.CompareUIPlugin.findStructureViewer(CompareUIPlugin.java:867) at org.eclipse.compare.CompareUI.findStructureViewer(CompareUI.java:321) at org.eclipse.compare.CompareEditorInput.findStructureViewer(CompareEditorInput.java:893) at org.eclipse.compare.internal.CompareStructureViewerSwitchingPane.getViewer(CompareStructureViewerSwitchingPane.java:87) at org.eclipse.compare.CompareEditorInput$2.getViewer(CompareEditorInput.java:684) at org.eclipse.compare.CompareViewerSwitchingPane.setInput(CompareViewerSwitchingPane.java:258) at org.eclipse.compare.internal.CompareStructureViewerSwitchingPane.setInput(CompareStructureViewerSwitchingPane.java:140) at org.eclipse.compare.CompareEditorInput.feedInput(CompareEditorInput.java:716) at org.eclipse.compare.CompareEditorInput.createContents(CompareEditorInput.java:543) at org.eclipse.compare.internal.CompareEditor.createCompareControl(CompareEditor.java:448) at org.eclipse.compare.internal.CompareEditor.createPartControl(CompareEditor.java:400) at org.eclipse.ui.internal.e4.compatibility.CompatibilityPart.createPartControl(CompatibilityPart.java:160) at org.eclipse.ui.internal.e4.compatibility.CompatibilityEditor.createPartControl(CompatibilityEditor.java:96) at org.eclipse.ui.internal.e4.compatibility.CompatibilityPart.create(CompatibilityPart.java:367) at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) at java.base/java.lang.reflect.Method.invoke(Method.java:580)

Strange. I'll provide null check for it

@SougandhS SougandhS force-pushed the CmpreSelcWithClip branch 2 times, most recently from 51a12e2 to b9af0a3 Compare May 13, 2025 12:47
@SougandhS
Copy link
Contributor Author

Calling compare on some files switching the project results in the following exception for me:
java.lang.NullPointerException: Cannot invoke "String.getBytes(java.nio.charset.Charset)" because "this.content" is null at

Reproduced and handled this now

@SougandhS SougandhS force-pushed the CmpreSelcWithClip branch from b9af0a3 to 5746f48 Compare May 14, 2025 00:24
@vogella vogella force-pushed the CmpreSelcWithClip branch from 5746f48 to b3f124c Compare May 16, 2025 06:37
@vogella
Copy link
Contributor

vogella commented May 16, 2025

Testing this again.

I don't think compare is correct for this example:

  • Create a text file, in my example lars.adoc with the following content:
lars
testing
compare
asdfklklsdf
  • Copy the last two lines into the clipbard.
  • Select the file and select compare with clipboard
  • Result:

image

@SougandhS please have a look

@SougandhS SougandhS force-pushed the CmpreSelcWithClip branch from b3f124c to 73d7e06 Compare May 16, 2025 07:09
@SougandhS
Copy link
Contributor Author

@SougandhS please have a look

Thanks for this case. Its fixed now

bugfix.mp4

@SougandhS SougandhS force-pushed the CmpreSelcWithClip branch from 73d7e06 to 8e6cd5f Compare June 6, 2025 00:27
@eclipse-platform-bot
Copy link
Contributor

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

runtime/features/org.eclipse.core.runtime.feature/feature.xml
team/bundles/org.eclipse.compare/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 5235abd65c5021830d5a014b1f0ac0a58dcfa013 Mon Sep 17 00:00:00 2001
From: Eclipse Platform Bot <[email protected]>
Date: Fri, 6 Jun 2025 00:32:41 +0000
Subject: [PATCH] Version bump(s) for 4.37 stream


diff --git a/runtime/features/org.eclipse.core.runtime.feature/feature.xml b/runtime/features/org.eclipse.core.runtime.feature/feature.xml
index be6874fea0..5e0968005c 100644
--- a/runtime/features/org.eclipse.core.runtime.feature/feature.xml
+++ b/runtime/features/org.eclipse.core.runtime.feature/feature.xml
@@ -2,7 +2,7 @@
 <feature
       id="org.eclipse.core.runtime.feature"
       label="%featureName"
-      version="1.4.800.qualifier"
+      version="1.4.900.qualifier"
       provider-name="%providerName"
       license-feature="org.eclipse.license"
       license-feature-version="0.0.0">
diff --git a/team/bundles/org.eclipse.compare/META-INF/MANIFEST.MF b/team/bundles/org.eclipse.compare/META-INF/MANIFEST.MF
index ec3108b1e7..f7ee13dfda 100644
--- a/team/bundles/org.eclipse.compare/META-INF/MANIFEST.MF
+++ b/team/bundles/org.eclipse.compare/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
 Bundle-ManifestVersion: 2
 Bundle-Name: %pluginName
 Bundle-SymbolicName: org.eclipse.compare; singleton:=true
-Bundle-Version: 3.11.400.qualifier
+Bundle-Version: 3.11.500.qualifier
 Bundle-Activator: org.eclipse.compare.internal.CompareUIPlugin
 Bundle-Vendor: %providerName
 Bundle-Localization: plugin
-- 
2.49.0

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

@SougandhS SougandhS force-pushed the CmpreSelcWithClip branch 2 times, most recently from 3f5929e to e4a67e0 Compare June 11, 2025 12:28
@SougandhS
Copy link
Contributor Author

Hi @vogella , could you please review this when you have time?

@SougandhS SougandhS force-pushed the CmpreSelcWithClip branch from e4a67e0 to 3ca13a3 Compare June 23, 2025 06:10
Allows users to compare or replace either the selected text or the
entire editor content against the clipboard content
@SougandhS SougandhS force-pushed the CmpreSelcWithClip branch from 3ca13a3 to e8d0937 Compare July 2, 2025 10:43
@vogella
Copy link
Contributor

vogella commented Jul 2, 2025

LGTM, thanks @SougandhS

@vogella vogella merged commit 2fe0e8d into eclipse-platform:master Jul 2, 2025
18 checks passed
@vogella
Copy link
Contributor

vogella commented Jul 2, 2025

@SougandhS can you please add this to the N&N for the next release? I think this would be the place: https://github.com/eclipse-platform/www.eclipse.org-eclipse/blob/master/news/4.37/platform.md

@SougandhS
Copy link
Contributor Author

Thank you @vogella & @iloveeclipse for the review

can you please add this to the N&N for the next release? I think this would be the place:

Sure 👍

@iloveeclipse
Copy link
Member

There is a problem (at least for me it is one) with the compare editor, which will be visible if you compare what AnyEdit provides with the current implementation. Please make sure the compare allows to modify the text file, currently it only allows read-only mode.

@SougandhS
Copy link
Contributor Author

There is a problem (at least for me it is one) with the compare editor, which will be visible if you compare what AnyEdit provides with the current implementation. Please make sure the compare allows to modify the text file, currently it only allows read-only mode.

I will provide a patch for that 👍

SougandhS added a commit to SougandhS/www.eclipse.org-eclipse that referenced this pull request Jul 3, 2025
SougandhS added a commit to SougandhS/www.eclipse.org-eclipse that referenced this pull request Jul 3, 2025
SougandhS added a commit to SougandhS/www.eclipse.org-eclipse that referenced this pull request Jul 3, 2025
SougandhS added a commit to SougandhS/www.eclipse.org-eclipse that referenced this pull request Jul 3, 2025
SougandhS added a commit to SougandhS/www.eclipse.org-eclipse that referenced this pull request Jul 3, 2025
merks pushed a commit to eclipse-platform/www.eclipse.org-eclipse that referenced this pull request Jul 3, 2025
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.

4 participants