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

Adding the possibility to enrich hovers with additional data #210472

Merged
merged 110 commits into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
110 commits
Select commit Hold shift + click to select a range
ef39b20
wip
aiday-mar Feb 8, 2024
0a4bef1
adding the boolean extended
aiday-mar Feb 15, 2024
be8a5c1
on shift, we show the extended hover
aiday-mar Feb 15, 2024
3d6459f
creating instead an api proposal
aiday-mar Feb 15, 2024
8727fa8
adding code in order to propagate the extended keyword
aiday-mar Feb 15, 2024
818a6d0
adding code in order to use insead an additional action, show extende…
aiday-mar Feb 15, 2024
3e6b577
making changes so one can transition to more extended information
aiday-mar Feb 15, 2024
423994c
making hover correctly appear
aiday-mar Feb 16, 2024
5c7b3d8
adding a setting and showing instead the extended hover information.
aiday-mar Feb 16, 2024
357e8bf
making chanegs
aiday-mar Feb 16, 2024
e85df6c
polishing the code
aiday-mar Feb 19, 2024
ab57fa9
extending the hover
aiday-mar Mar 6, 2024
d342e4b
adding the actions into a toolbar in the markdown hover when it can b…
aiday-mar Mar 6, 2024
f90f526
adding code in order to align the actions
aiday-mar Mar 7, 2024
c2e2a5e
changing the code so as to directly have the code inside of the markd…
aiday-mar Mar 7, 2024
0f2f5cb
refactoring the code
aiday-mar Mar 8, 2024
e6c0a45
polishing the code
aiday-mar Mar 8, 2024
5addb57
polishing the code
aiday-mar Mar 8, 2024
b263f15
adding the disposable store into the markdown hover participant
aiday-mar Mar 8, 2024
4c56bcb
letting the disposable store be undefined
aiday-mar Mar 8, 2024
a80074a
adding the on contents changes into the extend or constract focused m…
aiday-mar Mar 11, 2024
5b337a6
polish
aiday-mar Mar 11, 2024
6ed3d9f
changing the UI to chevron up and chevron down
aiday-mar Mar 11, 2024
c2accf2
setting different opacity level
aiday-mar Mar 11, 2024
24bee31
removing the refactoring
aiday-mar Mar 11, 2024
3f40d33
fixing compile errors
aiday-mar Mar 11, 2024
4ac442e
Merge branch 'main' into aiday/hoverExtension
aiday-mar Mar 11, 2024
9830188
changing the api
aiday-mar Mar 11, 2024
a288dad
polishing the code
aiday-mar Mar 11, 2024
ec45651
adding proposed api provideHover
aiday-mar Mar 12, 2024
79d8372
renaming the variables
aiday-mar Mar 12, 2024
f97c977
setting the boolean to undefined
aiday-mar Mar 12, 2024
336511a
polishing the code
aiday-mar Mar 12, 2024
ecaf126
polishing the code
aiday-mar Mar 12, 2024
1b66dc0
clearing the map instead
aiday-mar Mar 12, 2024
cb91f82
removing unused import
aiday-mar Mar 12, 2024
7d115e4
exchanging order of parameters, was causing token to be undefined?
aiday-mar Mar 12, 2024
b874755
calling justify content in order to center the content
aiday-mar Mar 13, 2024
dc37c8a
adding tooltip information
aiday-mar Mar 13, 2024
b10f70f
adding the keybinding service as a dependency
aiday-mar Mar 13, 2024
17f474e
using the hover context from the languages folder
aiday-mar Mar 13, 2024
e21fbe2
calling directly the method of interest
aiday-mar Mar 14, 2024
8a24d07
renaming the provider to source provider
aiday-mar Mar 14, 2024
0d4ffa4
adding a comment into the doc string
aiday-mar Mar 14, 2024
380b376
using a delta to increase the level by a specific number
aiday-mar Mar 14, 2024
c507ecd
saving directly the position, not the anchor
aiday-mar Mar 14, 2024
013a803
renaming the proposed API
aiday-mar Mar 14, 2024
e8b1471
separating into action and the enablement state
aiday-mar Mar 14, 2024
38b22ae
renaming the focus info
aiday-mar Mar 14, 2024
079e0ac
redefining the variable _focusInfo
aiday-mar Mar 14, 2024
de10c1a
using an array instead of a map
aiday-mar Mar 14, 2024
38c7a76
using instead the start range
aiday-mar Mar 14, 2024
6e8d8e9
defining directly the type
aiday-mar Mar 14, 2024
3ee89c3
removing the metadata on registration
aiday-mar Mar 14, 2024
1e8b2a3
adding changes directly to class Hover
aiday-mar Mar 14, 2024
f217d6f
placing the icons on the bottom left instead
aiday-mar Mar 14, 2024
b7de695
adding code to enable sending the initial hover
aiday-mar Mar 14, 2024
5fb5bee
Placing the VerboseHover class once again into the proposed API file
aiday-mar Mar 14, 2024
073317f
polishing the code
aiday-mar Mar 14, 2024
94a4e26
checking if the actions should be added as appropriate
aiday-mar Mar 14, 2024
53f1f14
changing font size
aiday-mar Mar 15, 2024
95e9c01
sending the whole hover in the hover context
aiday-mar Mar 15, 2024
7117aa6
saving the hover parts directly
aiday-mar Mar 15, 2024
901296e
render hover parts on markdown hover or verbose markdown hover
aiday-mar Mar 15, 2024
be380d0
polish hover
aiday-mar Mar 15, 2024
f8bcd67
making hover and verbosity action optional in context
aiday-mar Mar 20, 2024
15442c8
range and markdown cloning
aiday-mar Mar 20, 2024
936ff77
do not need the hover indices array
aiday-mar Mar 20, 2024
8a8f1d6
using same disposable store
aiday-mar Mar 20, 2024
9a97a31
changing the order
aiday-mar Mar 20, 2024
a117b51
remove space
aiday-mar Mar 20, 2024
6f5e91d
removing the cloning functions
aiday-mar Mar 21, 2024
7aa73bb
directly placing cloneHover in the map
aiday-mar Mar 21, 2024
710620d
adding changes from review
aiday-mar Apr 2, 2024
59343d0
polishing
aiday-mar Apr 3, 2024
d8bd14b
polishing the code
aiday-mar Apr 4, 2024
cf68733
polishing, requires some more polishing
aiday-mar Apr 4, 2024
e84d450
renaming code
aiday-mar Apr 5, 2024
0c1a32f
making check that hoverpart is of the appropriate type and we can inc…
aiday-mar Apr 5, 2024
94acd4f
Merge branch 'main' into aiday/hoverExtension
aiday-mar Apr 8, 2024
93fc5a9
using instead the hover service setupUpdatableHover instead of setupC…
aiday-mar Apr 8, 2024
d393019
erfactoring the code
aiday-mar Apr 8, 2024
a3cd5a2
check not undefined
aiday-mar Apr 8, 2024
a8a3aa6
polishing the pr
aiday-mar Apr 8, 2024
14df920
renaming the variables
aiday-mar Apr 8, 2024
7bc7c95
changing the condition in the if statement
aiday-mar Apr 8, 2024
7723d46
simplifying the types
aiday-mar Apr 9, 2024
7b1426d
polishing the code
aiday-mar Apr 9, 2024
150ad26
polishing
aiday-mar Apr 10, 2024
484795a
adding disposal logic
aiday-mar Apr 10, 2024
35019d3
adding disposal mechanism
aiday-mar Apr 10, 2024
0935dcc
remove the second parameter
aiday-mar Apr 10, 2024
55f878a
Merge branch 'main' into aiday/hoverExtension
aiday-mar Apr 12, 2024
d8b0bb7
polishing the code
aiday-mar Apr 12, 2024
692d65d
adding a separate file for the hover action ids
aiday-mar Apr 12, 2024
ab029cd
removing horizontal scrollbar checks in the content widget
aiday-mar Apr 12, 2024
d04e6bb
allowing to increase the hover height by 2 px more
aiday-mar Apr 12, 2024
ef2bfb8
wip
aiday-mar Apr 16, 2024
5cbe09f
fixing compiler errors, look again at the code
aiday-mar Apr 16, 2024
66d94ca
Merge branch 'main' into aiday/hoverExtension
aiday-mar Apr 16, 2024
10248d4
fixing some issues after compilation
aiday-mar Apr 16, 2024
910d013
removing spaces
aiday-mar Apr 16, 2024
2e43a25
remove disposable work since using finalization registry
aiday-mar Apr 16, 2024
12d6cff
cleaning the code
aiday-mar Apr 16, 2024
220fbb0
positioning instead at the start with a padding top
aiday-mar Apr 16, 2024
281efa5
removing from map when size exceeds 10
aiday-mar Apr 18, 2024
4e632f1
resetting the flex direction
aiday-mar Apr 18, 2024
1392993
polishing the code
aiday-mar Apr 19, 2024
b50bd3c
Merge branch 'main' into aiday/hoverExtension2
aiday-mar Apr 19, 2024
0331d65
placing the constant as a static private variable
aiday-mar Apr 19, 2024
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
42 changes: 27 additions & 15 deletions src/vs/base/browser/ui/hover/hoverWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,21 +67,8 @@ export class HoverAction extends Disposable {
const label = dom.append(this.action, $('span'));
label.textContent = keybindingLabel ? `${actionOptions.label} (${keybindingLabel})` : actionOptions.label;

this._register(dom.addDisposableListener(this.actionContainer, dom.EventType.CLICK, e => {
e.stopPropagation();
e.preventDefault();
actionOptions.run(this.actionContainer);
}));

this._register(dom.addDisposableListener(this.actionContainer, dom.EventType.KEY_DOWN, e => {
const event = new StandardKeyboardEvent(e);
if (event.equals(KeyCode.Enter) || event.equals(KeyCode.Space)) {
e.stopPropagation();
e.preventDefault();
actionOptions.run(this.actionContainer);
}
}));

this._store.add(new ClickAction(this.actionContainer, actionOptions.run));
this._store.add(new KeyDownAction(this.actionContainer, actionOptions.run, [KeyCode.Enter, KeyCode.Space]));
this.setEnabled(true);
}

Expand All @@ -99,3 +86,28 @@ export class HoverAction extends Disposable {
export function getHoverAccessibleViewHint(shouldHaveHint?: boolean, keybinding?: string | null): string | undefined {
return shouldHaveHint && keybinding ? localize('acessibleViewHint', "Inspect this in the accessible view with {0}.", keybinding) : shouldHaveHint ? localize('acessibleViewHintNoKbOpen', "Inspect this in the accessible view via the command Open Accessible View which is currently not triggerable via keybinding.") : '';
}

export class ClickAction extends Disposable {
constructor(container: HTMLElement, run: (container: HTMLElement) => void) {
super();
this._register(dom.addDisposableListener(container, dom.EventType.CLICK, e => {
e.stopPropagation();
e.preventDefault();
run(container);
}));
}
}

export class KeyDownAction extends Disposable {
constructor(container: HTMLElement, run: (container: HTMLElement) => void, keyCodes: KeyCode[]) {
super();
this._register(dom.addDisposableListener(container, dom.EventType.KEY_DOWN, e => {
const event = new StandardKeyboardEvent(e);
if (keyCodes.some(keyCode => event.equals(keyCode))) {
e.stopPropagation();
e.preventDefault();
run(container);
}
}));
}
}
38 changes: 35 additions & 3 deletions src/vs/editor/common/languages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,19 +168,51 @@ export interface Hover {
* current position itself.
*/
range?: IRange;

/**
* Can increase the verbosity of the hover
*/
canIncreaseVerbosity?: boolean;

/**
* Can decrease the verbosity of the hover
*/
canDecreaseVerbosity?: boolean;
}

/**
* The hover provider interface defines the contract between extensions and
* the [hover](https://code.visualstudio.com/docs/editor/intellisense)-feature.
*/
export interface HoverProvider {
export interface HoverProvider<THover = Hover> {
/**
* Provide a hover for the given position and document. Multiple hovers at the same
* Provide a hover for the given position, context and document. Multiple hovers at the same
* position will be merged by the editor. A hover can have a range which defaults
* to the word range at the position when omitted.
*/
provideHover(model: model.ITextModel, position: Position, token: CancellationToken): ProviderResult<Hover>;
provideHover(model: model.ITextModel, position: Position, token: CancellationToken, context?: HoverContext<THover>): ProviderResult<Hover>;
}

export interface HoverContext<THover = Hover> {
/**
* Whether to increase or decrease the hover's verbosity
*/
action?: HoverVerbosityAction;
/**
* The previous hover for the same position
*/
previousHover?: THover;
}

export enum HoverVerbosityAction {
/**
* Increase the verbosity of the hover
*/
Increase,
/**
* Decrease the verbosity of the hover
*/
Decrease
}

/**
Expand Down
11 changes: 11 additions & 0 deletions src/vs/editor/common/standalone/standaloneEnums.ts
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,17 @@ export enum GlyphMarginLane {
Right = 3
}

export enum HoverVerbosityAction {
/**
* Increase the verbosity of the hover
*/
Increase = 0,
/**
* Decrease the verbosity of the hover
*/
Decrease = 1
}

/**
* Describes what to do with the indentation when pressing Enter.
*/
Expand Down
15 changes: 14 additions & 1 deletion src/vs/editor/contrib/hover/browser/contentHoverController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ import { HoverOperation, HoverStartMode, HoverStartSource } from 'vs/editor/cont
import { HoverAnchor, HoverParticipantRegistry, HoverRangeAnchor, IEditorHoverColorPickerWidget, IEditorHoverParticipant, IEditorHoverRenderContext, IHoverPart, IHoverWidget } from 'vs/editor/contrib/hover/browser/hoverTypes';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { MarkdownHoverParticipant } from 'vs/editor/contrib/hover/browser/markdownHoverParticipant';
import { InlayHintsHover } from 'vs/editor/contrib/inlayHints/browser/inlayHintsHover';
import { HoverVerbosityAction } from 'vs/editor/common/standalone/standaloneEnums';
import { ContentHoverWidget } from 'vs/editor/contrib/hover/browser/contentHoverWidget';
import { ContentHoverComputer } from 'vs/editor/contrib/hover/browser/contentHoverComputer';
import { ContentHoverVisibleData, HoverResult } from 'vs/editor/contrib/hover/browser/contentHoverTypes';
Expand All @@ -28,6 +31,8 @@ export class ContentHoverController extends Disposable implements IHoverWidget {
private readonly _computer: ContentHoverComputer;
private readonly _widget: ContentHoverWidget;
private readonly _participants: IEditorHoverParticipant[];
// TODO@aiday-mar make array of participants, dispatch between them
private readonly _markdownHoverParticipant: MarkdownHoverParticipant | undefined;
private readonly _hoverOperation: HoverOperation<IHoverPart>;

constructor(
Expand All @@ -42,7 +47,11 @@ export class ContentHoverController extends Disposable implements IHoverWidget {
// Instantiate participants and sort them by `hoverOrdinal` which is relevant for rendering order.
this._participants = [];
for (const participant of HoverParticipantRegistry.getAll()) {
this._participants.push(this._instantiationService.createInstance(participant, this._editor));
const participantInstance = this._instantiationService.createInstance(participant, this._editor);
if (participantInstance instanceof MarkdownHoverParticipant && !(participantInstance instanceof InlayHintsHover)) {
this._markdownHoverParticipant = participantInstance;
}
this._participants.push(participantInstance);
}
this._participants.sort((p1, p2) => p1.hoverOrdinal - p2.hoverOrdinal);

Expand Down Expand Up @@ -342,6 +351,10 @@ export class ContentHoverController extends Disposable implements IHoverWidget {
this._startShowingOrUpdateHover(new HoverRangeAnchor(0, range, undefined, undefined), mode, source, focus, null);
}

public async updateFocusedMarkdownHoverVerbosityLevel(action: HoverVerbosityAction): Promise<void> {
this._markdownHoverParticipant?.updateFocusedMarkdownHoverPartVerbosityLevel(action);
}

public getWidgetContent(): string | undefined {
const node = this._widget.getDomNode();
if (!node.textContent) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export class EditorHoverStatusBar extends Disposable implements IEditorHoverStat
) {
super();
this.hoverElement = $('div.hover-row.status-bar');
this.hoverElement.tabIndex = 0;
this.actionsElement = dom.append(this.hoverElement, $('div.actions'));
}

Expand Down
27 changes: 14 additions & 13 deletions src/vs/editor/contrib/hover/browser/getHover.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,31 +21,32 @@ export class HoverProviderResult {
) { }
}

/**
* Does not throw or return a rejected promise (returns undefined instead).
*/
async function executeProvider(provider: HoverProvider, ordinal: number, model: ITextModel, position: Position, token: CancellationToken): Promise<HoverProviderResult | undefined> {
try {
const result = await Promise.resolve(provider.provideHover(model, position, token));
if (result && isValid(result)) {
return new HoverProviderResult(provider, result, ordinal);
}
} catch (err) {
onUnexpectedExternalError(err);
const result = await Promise
.resolve(provider.provideHover(model, position, token))
.catch(onUnexpectedExternalError);
if (!result || !isValid(result)) {
return undefined;
}
return undefined;
return new HoverProviderResult(provider, result, ordinal);
}

export function getHover(registry: LanguageFeatureRegistry<HoverProvider>, model: ITextModel, position: Position, token: CancellationToken): AsyncIterableObject<HoverProviderResult> {
export function getHoverProviderResultsAsAsyncIterable(registry: LanguageFeatureRegistry<HoverProvider>, model: ITextModel, position: Position, token: CancellationToken): AsyncIterableObject<HoverProviderResult> {
const providers = registry.ordered(model);
const promises = providers.map((provider, index) => executeProvider(provider, index, model, position, token));
return AsyncIterableObject.fromPromises(promises).coalesce();
}

export function getHoverPromise(registry: LanguageFeatureRegistry<HoverProvider>, model: ITextModel, position: Position, token: CancellationToken): Promise<Hover[]> {
return getHover(registry, model, position, token).map(item => item.hover).toPromise();
export function getHoversPromise(registry: LanguageFeatureRegistry<HoverProvider>, model: ITextModel, position: Position, token: CancellationToken): Promise<Hover[]> {
return getHoverProviderResultsAsAsyncIterable(registry, model, position, token).map(item => item.hover).toPromise();
}

registerModelAndPositionCommand('_executeHoverProvider', (accessor, model, position) => {
registerModelAndPositionCommand('_executeHoverProvider', (accessor, model, position): Promise<Hover[]> => {
const languageFeaturesService = accessor.get(ILanguageFeaturesService);
return getHoverPromise(languageFeaturesService.hoverProvider, model, position, CancellationToken.None);
return getHoversPromise(languageFeaturesService.hoverProvider, model, position, CancellationToken.None);
});

function isValid(result: Hover) {
Expand Down
22 changes: 22 additions & 0 deletions src/vs/editor/contrib/hover/browser/hover.css
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,28 @@
flex-direction: column;
}

.monaco-editor .monaco-hover .hover-row .verbosity-actions {
display: flex;
flex-direction: column;
padding-left: 5px;
padding-right: 5px;
justify-content: end;
border-right: 1px solid var(--vscode-editorHoverWidget-border);
}

.monaco-editor .monaco-hover .hover-row .verbosity-actions .codicon {
cursor: pointer;
font-size: 11px;
}

.monaco-editor .monaco-hover .hover-row .verbosity-actions .codicon.enabled {
color: var(--vscode-textLink-foreground);
}

.monaco-editor .monaco-hover .hover-row .verbosity-actions .codicon.disabled {
opacity: 0.6;
}

.monaco-editor .monaco-hover .hover-row .actions {
background-color: var(--vscode-editorHoverWidget-statusBarBackground);
}
Expand Down
2 changes: 2 additions & 0 deletions src/vs/editor/contrib/hover/browser/hoverActionIds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ export const PAGE_UP_HOVER_ACTION_ID = 'editor.action.pageUpHover';
export const PAGE_DOWN_HOVER_ACTION_ID = 'editor.action.pageDownHover';
export const GO_TO_TOP_HOVER_ACTION_ID = 'editor.action.goToTopHover';
export const GO_TO_BOTTOM_HOVER_ACTION_ID = 'editor.action.goToBottomHover';
export const INCREASE_HOVER_VERBOSITY_ACTION_ID = 'editor.action.increaseHoverVerbosityLevel';
export const DECREASE_HOVER_VERBOSITY_ACTION_ID = 'editor.action.decreaseHoverVerbosityLevel';
51 changes: 50 additions & 1 deletion src/vs/editor/contrib/hover/browser/hoverActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { GO_TO_BOTTOM_HOVER_ACTION_ID, GO_TO_TOP_HOVER_ACTION_ID, PAGE_DOWN_HOVER_ACTION_ID, PAGE_UP_HOVER_ACTION_ID, SCROLL_DOWN_HOVER_ACTION_ID, SCROLL_LEFT_HOVER_ACTION_ID, SCROLL_RIGHT_HOVER_ACTION_ID, SCROLL_UP_HOVER_ACTION_ID, SHOW_DEFINITION_PREVIEW_HOVER_ACTION_ID, SHOW_OR_FOCUS_HOVER_ACTION_ID } from 'vs/editor/contrib/hover/browser/hoverActionIds';
import { DECREASE_HOVER_VERBOSITY_ACTION_ID, GO_TO_BOTTOM_HOVER_ACTION_ID, GO_TO_TOP_HOVER_ACTION_ID, INCREASE_HOVER_VERBOSITY_ACTION_ID, PAGE_DOWN_HOVER_ACTION_ID, PAGE_UP_HOVER_ACTION_ID, SCROLL_DOWN_HOVER_ACTION_ID, SCROLL_LEFT_HOVER_ACTION_ID, SCROLL_RIGHT_HOVER_ACTION_ID, SCROLL_UP_HOVER_ACTION_ID, SHOW_DEFINITION_PREVIEW_HOVER_ACTION_ID, SHOW_OR_FOCUS_HOVER_ACTION_ID } from 'vs/editor/contrib/hover/browser/hoverActionIds';
import { KeyChord, KeyCode, KeyMod } from 'vs/base/common/keyCodes';
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
import { EditorAction, ServicesAccessor } from 'vs/editor/browser/editorExtensions';
Expand All @@ -15,6 +15,7 @@ import { HoverStartMode, HoverStartSource } from 'vs/editor/contrib/hover/browse
import { AccessibilitySupport } from 'vs/platform/accessibility/common/accessibility';
import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry';
import { HoverController } from 'vs/editor/contrib/hover/browser/hoverController';
import { HoverVerbosityAction } from 'vs/editor/common/languages';
import * as nls from 'vs/nls';
import 'vs/css!./hover';

Expand Down Expand Up @@ -418,3 +419,51 @@ export class GoToBottomHoverAction extends EditorAction {
controller.goToBottom();
}
}

export class IncreaseHoverVerbosityLevel extends EditorAction {

constructor() {
super({
id: INCREASE_HOVER_VERBOSITY_ACTION_ID,
label: nls.localize({
key: 'increaseHoverVerbosityLevel',
comment: ['Label for action that will increase the hover verbosity level.']
}, "Increase Hover Verbosity Level"),
alias: 'Increase Hover Verbosity Level',
precondition: EditorContextKeys.hoverFocused,
kbOpts: {
kbExpr: EditorContextKeys.hoverFocused,
primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KeyK, KeyMod.CtrlCmd | KeyCode.KeyP),
weight: KeybindingWeight.EditorContrib
}
});
}

public run(accessor: ServicesAccessor, editor: ICodeEditor): void {
HoverController.get(editor)?.updateFocusedMarkdownHoverVerbosityLevel(HoverVerbosityAction.Increase);
}
}

export class DecreaseHoverVerbosityLevel extends EditorAction {

constructor() {
super({
id: DECREASE_HOVER_VERBOSITY_ACTION_ID,
label: nls.localize({
key: 'decreaseHoverVerbosityLevel',
comment: ['Label for action that will decrease the hover verbosity level.']
}, "Decrease Hover Verbosity Level"),
alias: 'Decrease Hover Verbosity Level',
precondition: EditorContextKeys.hoverFocused,
kbOpts: {
kbExpr: EditorContextKeys.hoverFocused,
primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KeyK, KeyMod.CtrlCmd | KeyCode.KeyM),
weight: KeybindingWeight.EditorContrib
}
});
}

public run(accessor: ServicesAccessor, editor: ICodeEditor, args: any): void {
HoverController.get(editor)?.updateFocusedMarkdownHoverVerbosityLevel(HoverVerbosityAction.Decrease);
}
}
4 changes: 3 additions & 1 deletion src/vs/editor/contrib/hover/browser/hoverContribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { GoToBottomHoverAction, GoToTopHoverAction, PageDownHoverAction, PageUpHoverAction, ScrollDownHoverAction, ScrollLeftHoverAction, ScrollRightHoverAction, ScrollUpHoverAction, ShowDefinitionPreviewHoverAction, ShowOrFocusHoverAction } from 'vs/editor/contrib/hover/browser/hoverActions';
import { DecreaseHoverVerbosityLevel, GoToBottomHoverAction, GoToTopHoverAction, IncreaseHoverVerbosityLevel, PageDownHoverAction, PageUpHoverAction, ScrollDownHoverAction, ScrollLeftHoverAction, ScrollRightHoverAction, ScrollUpHoverAction, ShowDefinitionPreviewHoverAction, ShowOrFocusHoverAction } from 'vs/editor/contrib/hover/browser/hoverActions';
import { EditorContributionInstantiation, registerEditorAction, registerEditorContribution } from 'vs/editor/browser/editorExtensions';
import { editorHoverBorder } from 'vs/platform/theme/common/colorRegistry';
import { registerThemingParticipant } from 'vs/platform/theme/common/themeService';
Expand All @@ -24,6 +24,8 @@ registerEditorAction(PageUpHoverAction);
registerEditorAction(PageDownHoverAction);
registerEditorAction(GoToTopHoverAction);
registerEditorAction(GoToBottomHoverAction);
registerEditorAction(IncreaseHoverVerbosityLevel);
registerEditorAction(DecreaseHoverVerbosityLevel);
HoverParticipantRegistry.register(MarkdownHoverParticipant);
HoverParticipantRegistry.register(MarkerHoverParticipant);

Expand Down
5 changes: 5 additions & 0 deletions src/vs/editor/contrib/hover/browser/hoverController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { IHoverWidget } from 'vs/editor/contrib/hover/browser/hoverTypes';
import { InlineSuggestionHintsContentWidget } from 'vs/editor/contrib/inlineCompletions/browser/inlineCompletionsHintsWidget';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { ResultKind } from 'vs/platform/keybinding/common/keybindingResolver';
import { HoverVerbosityAction } from 'vs/editor/common/languages';
import { RunOnceScheduler } from 'vs/base/common/async';
import { ContentHoverWidget } from 'vs/editor/contrib/hover/browser/contentHoverWidget';
import { ContentHoverController } from 'vs/editor/contrib/hover/browser/contentHoverController';
Expand Down Expand Up @@ -401,6 +402,10 @@ export class HoverController extends Disposable implements IEditorContribution {
return this._contentWidget?.widget.isResizing || false;
}

public updateFocusedMarkdownHoverVerbosityLevel(action: HoverVerbosityAction): void {
this._getOrCreateContentWidget().updateFocusedMarkdownHoverVerbosityLevel(action);
}

public focus(): void {
this._contentWidget?.focus();
}
Expand Down
Loading
Loading