Can a VSCode extension trigger a function when a user hovers over a diagnostic? - visual-studio-code

Diagnostics show more information when hovering over them. I would like to trigger a function whenever the user hovers and stops hovering over the diagnostic area. Is this currently possible with an extension?

There is a new context key coming in v1.46 presumably, see editor hover context key.
editorHoverVisible
which is perhaps of some help. I don't know how to detect precisely where that hover occurred though.

Related

VSCode - Disable selection on auto-complete suggestion

Whenever I use autocomplete, VSCode automatically puts whatever I type in a selection, it didn't happen before and it only started happening recently.
Here's what happens:
I type something like this and suggestion comes up:
Then I press enter to auto complete:
All of this is fine, but when I start typing in the quotes:
VSCode automatically puts my text in a selection. This causes multiple problems. Suggestions get disabled in selection and I have to press Esc everytime I want the selection disabled.
Is there any way to fix this?
The question was already answered by #Anton Solomin and #devanil. The issue is VS code auto-suggestion is not working when text is highlighted, because some of your code snippet is preventing quick suggestion by VS code.
So just tell VS code that don't disable quick suggestion if some snippets askes you to do it.
Go to VScode settings page, in settings search bar type editor.suggest.snippetsPreventQuickSuggestions
Uncheck Controls whether an active snippet prevents quick suggestion

Access mouse over hover in VSCode

Is there a way to access the mouse over popup in VSCode via Keyboard and navigate in it?
I often use the mouse over to get the namespace of function or variable ...
So I want to place the cursor on "bar", popup the hover (Show Hover Ctrl+k Ctrl+i), focus it, mark some text (eg. namespace::functioname), copy and close the hover.
namespace foo{
void bar();
}
First problem, the hover doesn't get the focus and I don't know how to focus it. But there is another feature "Show defintion preview hover", which actually gets focused. So far so good. But I still cannot mark or copy text inside the hover via keyboard.
Show hover (not focused):
Show definition preview hover (focused):
But I still cannot mark or copy text inside the hover via keyboard.
That should change with VSCode 1.68 (May 2022):
Lock hovers to more easily mouse over them
Some custom hovers cannot be moused over and others are tricky to mouse over without hiding it because of other things in the way (eg. like a scroll bar).
Holding alt while a hover is active will now "lock" it, giving it a wider border and preventing moving the mouse outside of the hover widget or whatever triggered it from hiding it.
This is primarily an accessibility feature to make hovers play nice with screen magnifiers but it is also useful for copying text from certain hovers.
Note that this feature only applies outside of the editor because editor hovers can always be moused over unless specified otherwise via a setting.
This will be helpful for other views (debug, terminal, ...) where variables with their popup can appear as well.
In the editor, see microsoft/vscode issue 63296
ctrl+K ctrl+I to show the hover and focus it
ctrl+A to select all the hover content
ctrl+C to copy to clipboard
It does indeed work for me (on windows) for the first two steps, however ctrl+C does not copy the text selected with ctrl+A.
It seems like there are two different selections possible in the hover:
ctrl+Aselects everything with a dark blue.
When selecting some text in the hover with the mouse (i.e. press the left mouse button while near/over a char, move mouse, release left mouse button) the selected text is shown in a lighter and brighter blue.
The two selections can coexist.
ctrl+C always copies the text selected with the mouse, or nothing if there's no such selection, no matter whether a ctrl+A selection also has been done.
If there's only a ctrl+A selection, ctrl+C doesn't copy anything.
The two selections can be selected in any order. The order doesn't change the behavior.
Think I found out what you were after.
The shortcut is: Ctrl+K Ctrl+I
See: Trigger advanced hover information with keyboard
please try control + mouse click
it may be help you

How to highlight MenuItem programmatically in SWT

I open a context menu programmatically. Now additionally I would like to highlight the first menu entry.
This highlighting happens when I move with the mouse over the context menu or press the arrow keys on the keyboard. I am interested how I can trigger this programmatically.
I know the API of MenuItem does not offer this feature out of the box. So I tried to fire some MouseEvents of the type MouseOver and MouseHover, but without any success.
Has anybody an idea how to implement this feature?
I am not sure if you can change menuitem highlight colors, I haven't seen any previous example before. Look at this though: Change eclipse menuitem color
If you want to simulate what the user does and if you happen to know the location of the menu item, you can use Display#setCursorLocation() to position the mouse pointer over the menu item.
Note however, that if and how a menu item is highlighted is platform specific.
You should not use this method other than for demonstration of test purposes. If your application needs to highlight or preselect an entry in a list of choices,
you should probably use another widget. If you more describe your use case, we may be able to find a suitable widget.

How to make GraphicalEditorWithFlyoutPalette's PaletteView visible on first start

My GEF editor (extending GraphicalEditorWithFlyoutPalette) always opens the editor with the palette hidden on first start of the application / first opening of the editor (after a build for example).
As this will potentially bewilder users who'll need to go in search of the flyout icon first, I'd like to have the palette view shown whenever the editor is opened. The user can then choose to close it on his/her preferences.
How can I achieve this? The API doesn't seem to give any clues, or I'm unable to find them...
The state of the palette defines if it is open or closed. This state is accessible using the getPalettePreferences().setPaletteState() method that is accessible in the GraphicalEditorWithFlyoutPalette. To open the palette, you must set it to the FlyoutPaletteComposite.STATE_PINNED_OPEN, like this:
getPalettePreferences().setPaletteState(FlyoutPaletteComposite.STATE_PINNED_OPEN);
If you want to ALWAYS override the state so that the palette is always opened with the editor, you have to add the line to the constructor of your editor. If you only want to do this once, and then leave the state as it was last selected by the user... No idea how to do this :-(

How to Display Current Function in Eclipse

I miss a certain functionality in Eclipse. I would like to know the name of the current function the cursor is currently inside. This is useful when browsing unknown code using the search function, for example.
Any idea how to show it? Maybe a plugin?
I'm using the "Toggle Breadcrumb" option from toolbar:
It shows a nice breadcrumb, ending with current function name.
It's quite handy for me, as Outline becomes cumbersome to use if you have zilions of functions.
It produces the following structure above your Java Editor (truncated at the picture below):
The "Outline" view shows the current function.
It may be necessary to enable the 'Link to Editor' option in the Outline View dropdown menu. This might be off by default for CDT.
I was looking for something similar (Xcode-like bar at the top showing the current function, where you can also go to another function by clicking on it to open a popup list of functions). Here is what I settled on with Eclipse 3.5.1 CDT:
I moved the Outline view to the top, resized it to make it a 1-line horizontal strip (don't make it too narrow), and selected "Link With Editor" in its menu, so that it always shows the current function. However, this doesn't open a popup list like Xcode. For that functionality, I assigned a shortcut to the "Show Outline" command which does open a popup list of all functions.
The Eclipse function 'show outline' will pop up a list of outline objects, and it will highlight the object your cursor is inside in grey. It's typically bound to 'ctrl-o' (the letter 'o', not zero), but you can re-bind it as you see fit. I'm running Eclipse with the CDT plugin and it works pretty well for me.
To enable the breadcrumb invoke Toggle Java Editor Breadcrumb in the toolbar or press Alt+Shift+B in the Java editor.
You can also display the Quick Outline (ctrl+o). This way you see the context quickly without having to have a permanent Outline Window linked to the Editor.
Use the "Link With Editor" option on the outline menu
Press Ctrl+o (cursor is currently inside a function at a particular line).
It highlights the current method, or name of the class if the cursor is outside the method body.
You can click on highlighted method.
It has got inline search feature ...start typing name of the method to navigate to the specified method or method with matching search pattern.
If you press again Ctrl+o to shows the inherited members/methods.
Using outline with "link with editor" option worked also for me, thanks!
Just an addition, you can move outline pane in to the same window group as search, progress etc. saves the space in your perspective instead of keeping it at another group.