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

Conversation

brychcy
Copy link
Contributor

@brychcy brychcy commented Jul 31, 2025

e.g. m2e's MavenPomEditor or PDE's ManifestEditor

e.g. m2e's MavenPomEditor or PDE's ManifestEditor

Signed-off-by: Till Brychcy <[email protected]>
@vogella
Copy link
Contributor

vogella commented Jul 31, 2025

@SougandhS can you review?

Copy link
Contributor

github-actions bot commented Jul 31, 2025

Test Results

 1 947 files  +  158   1 947 suites  +158   1h 32m 51s ⏱️ - 32m 30s
 4 720 tests ±    0   4 696 ✅ ±    0   24 💤 ±0  0 ❌ ±0 
14 160 runs  +1 117  13 993 ✅ +1 116  167 💤 +1  0 ❌ ±0 

Results for commit 9234bd4. ± Comparison against base commit c4f892a.

♻️ This comment has been updated with latest results.

Copy link
Contributor

@SougandhS SougandhS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested the changes & LGTM 👍
Thank you for the improvement

@tomaswolf
Copy link
Member

Why only FormEditor and not MultiPageEditorPart in general?

@SougandhS
Copy link
Contributor

Why only FormEditor and not MultiPageEditorPart in general?

I noticed thatMultiPageEditorPart.getActiveEditor()is a protected method, and since all comparison-related actions (including this one) extend from BaseCompareAction, we can't directly access it from here

Copy link
Contributor

@SougandhS SougandhS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@brychcy while you already fixed this issue for Compare, would it be possible to add the same change in org.eclipse.compare.internal.ClipboardReplace too ?

same code can be pasted before if (editor instanceof ITextEditor txtEditor) {

@brychcy
Copy link
Contributor Author

brychcy commented Aug 1, 2025

I can, but actually may I ask why "Replace With > Clipboard" exists at alll?

At least on macOS I can just do "paste" (CMD-V) and the current selection will be replaced with the clipboard contents. If I want to replace the whole file I can easily do "select all" (CMD-A) first.

Also the "Clipboard" entry is now in the "Replace With"-submenu in between "Local History..." and "Previous from Local History" and the feels really misplaced there (actually everything else in that submenu is also history related, so if you really wanted to keep it, maybe move it to the end?)

So in the current state I think this makes normal usage of "Replace With"-options harder to use.
I think it should either be move it somewhere else or removed again (better in my Opinion, as I don't see a use case)

@SougandhS
Copy link
Contributor

I can, but actually may I ask why "Replace With > Clipboard" exists at alll?

#1862 (comment)

Also the "Clipboard" entry is now in the "Replace With"-submenu in between "Local History..." and "Previous from Local History" and the feels really misplaced there (actually everything else in that submenu is also history related, so if you really wanted to keep it, maybe move it to the end?)

Yeah it can be moved to the end 👍

@brychcy
Copy link
Contributor Author

brychcy commented Aug 1, 2025

Also there are still some issues with "Replace With... > Clipboard".

E.g. it directly changes content of "derived" files.
Normally there should be a question "This file is derived. Do you really want to edit it?"

@brychcy
Copy link
Contributor Author

brychcy commented Aug 1, 2025

I can, but actually may I ask why "Replace With > Clipboard" exists at alll?

#1862 (comment)

I agree with that comment in that being able to compare files with the Clipboard is useful, but I disagree that adding "Replace" is a good idea

@SougandhS
Copy link
Contributor

E.g. it directly changes content of "derived" files. Normally there should be a question "This file is derived. Do you really want to edit it?"

Will check that. thanks for noticing 👍

@brychcy
Copy link
Contributor Author

brychcy commented Aug 1, 2025

Similar, "Replace with" doesn't check for "Locked"

@brychcy
Copy link
Contributor Author

brychcy commented Aug 1, 2025

Also "Replace With" applied on files should have "Undo" support

@brychcy
Copy link
Contributor Author

brychcy commented Aug 1, 2025

Anyways, thanks a lot for providing "Compare With..." Clipboard!
(that feature was actually one of the few reasons I sometimes launch IntelliJ)

e.g. m2e's MavenPomEditor or PDE's ManifestEditor

Signed-off-by: Till Brychcy <[email protected]>
@brychcy
Copy link
Contributor Author

brychcy commented Aug 1, 2025

Anyways I added the code as requested to ClipboardReplace, too, so we can close this.

@SougandhS
Copy link
Contributor

SougandhS commented Aug 1, 2025

Anyways I added the code as requested to ClipboardReplace, too, so we can close this.

Sorry for the late reply, I was at lunch.
You can revert changes for Replace, I will push a fix including this change later

@SougandhS
Copy link
Contributor

Anyways, thanks a lot for providing "Compare With..." Clipboard! (that feature was actually one of the few reasons I sometimes launch IntelliJ)

Thank you @brychcy

@SougandhS
Copy link
Contributor

Anyways I added the code as requested to ClipboardReplace, too, so we can close this.

Sorry for the late reply, I was at lunch. You can revert changes for Replace, I will push a fix including this change later

Taking this back, you keep this commit. Thank you for this again

@SougandhS
Copy link
Contributor

Hi @vogella
Can you merge this PR ?

@iloveeclipse iloveeclipse merged commit 401d483 into eclipse-platform:master Aug 1, 2025
18 checks passed
@iloveeclipse
Copy link
Member

Thanks everyone. Change looks good.

(that feature was actually one of the few reasons I sometimes launch IntelliJ)

The feature is part of AnyEdit since ~15 years or so :-)

@vogella
Copy link
Contributor

vogella commented Aug 1, 2025

Thanks @brychcy , nice to see you contributing again.

Thanks @SougandhS for the review

@tomaswolf
Copy link
Member

tomaswolf commented Aug 1, 2025

Why only FormEditor and not MultiPageEditorPart in general?

I noticed thatMultiPageEditorPart.getActiveEditor()is a protected method, and since all comparison-related actions (including this one) extend from BaseCompareAction, we can't directly access it from here

if (editor instanceof MultiPageEditorPart mpe) {
  Object page = mpe.getSelectedPage();
  if (page instanceof IEditorPart e) {
    editor = e;
  }
}

MultiPageEditorPart.getSelectedPage() is public, and its contract is to return the editor part if the current page is an editor part.

@brychcy
Copy link
Contributor Author

brychcy commented Aug 2, 2025

Interesting.
But then I wonder if there is a way to make "Compare With Clipboard" available to all Text Editors.
E.g. it currently doesn't work at all in the "Effective POM" tab of the Maven POM Editor, or in ClassFileEditor (when looking at the attached source code of .class files)

@tomaswolf
Copy link
Member

Interesting. But then I wonder if there is a way to make "Compare With Clipboard" available to all Text Editors. E.g. it currently doesn't work at all in the "Effective POM" tab of the Maven POM Editor, or in ClassFileEditor (when looking at the attached source code of .class files)

There is. Andrey's AnyEditTools can do that, too.

@SougandhS
Copy link
Contributor

MultiPageEditorPart.getSelectedPage() is public, and its contract is to return the editor part if the current page is an editor part.

Thanks for this, I have incorporated this change in #2007

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.

5 participants