Skip to content
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

feat: add "Copy Value" context menu item to LanguageServers view #1185

Merged
merged 1 commit into from
Jan 16, 2025

Conversation

sebthom
Copy link
Member

@sebthom sebthom commented Jan 15, 2025

This PR adds a context menu item to the Language Servers view to copy the selected cell as text to the clipboard. This is esp. handy for troubleshooting to copy the effective command line or PID of an LS.

image

@rubenporras
Copy link
Contributor

Should we not add the possibility to copy with the keyboard as well to make it behave as other menu items?

@sebthom
Copy link
Member Author

sebthom commented Jan 15, 2025

Should we not add the possibility to copy with the keyboard as well to make it behave as other menu items?

The view has full row selection. So when you press CTRL+C we don't know which value the user wants.

@rubenporras
Copy link
Contributor

Should we not add the possibility to copy with the keyboard as well to make it behave as other menu items?

The view has full row selection. So when you press CTRL+C we don't know which value the user wants.

I understand, if it will copy only one Cell, what about renaming the message as suggested?

@sebthom sebthom force-pushed the ls-view-copy-value branch from 0ab8646 to 97c2875 Compare January 15, 2025 22:41
@sebthom
Copy link
Member Author

sebthom commented Jan 15, 2025

@rubenporras I changed the implementation. You can now select a cell value and also use CTRL+C to copy the value

Copy link
Contributor

@rubenporras rubenporras left a comment

Choose a reason for hiding this comment

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

Thanks for taking up my comment on Ctrl-C.

copyValueMenuItem.setText("Copy Cell Value"); //$NON-NLS-1$
copyValueMenuItem.addListener(SWT.Selection, event -> copyCurrentCellToClipboard());
table.addListener(SWT.MouseDown, event -> {
if (event.button == 3 /* Right-click? */
Copy link
Contributor

Choose a reason for hiding this comment

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

very surprising that there is no better way to find if it is a right-click that hardcoding the number 3, but I could not find anything better in SWT; the documentation only says the button can be 1, 2, 3.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I was surprised by this as well. Ideally, I would use SWT.MenuDetect as the listener event, which would make this check unnecessary. However, for some reason, SWT.MenuDetect becomes unreliable when SWT.FULL_SELECTION is enabled on the table. Then it only triggers intermittently after several right mouse clicks.

@sebthom sebthom merged commit 30c3e79 into eclipse-lsp4e:main Jan 16, 2025
6 checks passed
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.

2 participants