Extract hover actions and hover contribution point into separate files (#210219)

* extracting actions into a separate file and contribution into a separate file

* updating the imports of the hover controller

* adding correct contribution point in editor.all.ts file
This commit is contained in:
Aiday Marlen Kyzy
2024-04-12 10:38:37 +02:00
committed by GitHub
parent 0934f1f198
commit 9deb01df50
13 changed files with 468 additions and 448 deletions
@@ -11,7 +11,7 @@ import { Range } from 'vs/editor/common/core/range';
import { IEditorContribution } from 'vs/editor/common/editorCommon';
import { ColorDecorationInjectedTextMarker } from 'vs/editor/contrib/colorPicker/browser/colorDetector';
import { ColorHoverParticipant } from 'vs/editor/contrib/colorPicker/browser/colorHoverParticipant';
import { HoverController } from 'vs/editor/contrib/hover/browser/hover';
import { HoverController } from 'vs/editor/contrib/hover/browser/hoverController';
import { HoverStartMode, HoverStartSource } from 'vs/editor/contrib/hover/browser/hoverOperation';
import { HoverParticipantRegistry } from 'vs/editor/contrib/hover/browser/hoverTypes';
@@ -0,0 +1,419 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { KeyChord, KeyCode, KeyMod } from 'vs/base/common/keyCodes';
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
import { EditorAction, ServicesAccessor } from 'vs/editor/browser/editorExtensions';
import { EditorOption } from 'vs/editor/common/config/editorOptions';
import { Range } from 'vs/editor/common/core/range';
import { EditorContextKeys } from 'vs/editor/common/editorContextKeys';
import { GotoDefinitionAtPositionEditorContribution } from 'vs/editor/contrib/gotoSymbol/browser/link/goToDefinitionAtPosition';
import { HoverStartMode, HoverStartSource } from 'vs/editor/contrib/hover/browser/hoverOperation';
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 * as nls from 'vs/nls';
import 'vs/css!./hover';
enum HoverFocusBehavior {
NoAutoFocus = 'noAutoFocus',
FocusIfVisible = 'focusIfVisible',
AutoFocusImmediately = 'autoFocusImmediately'
}
export class ShowOrFocusHoverAction extends EditorAction {
constructor() {
super({
id: 'editor.action.showHover',
label: nls.localize({
key: 'showOrFocusHover',
comment: [
'Label for action that will trigger the showing/focusing of a hover in the editor.',
'If the hover is not visible, it will show the hover.',
'This allows for users to show the hover without using the mouse.'
]
}, "Show or Focus Hover"),
metadata: {
description: nls.localize2('showOrFocusHoverDescription', 'Show or focus the editor hover which shows documentation, references, and other content for a symbol at the current cursor position.'),
args: [{
name: 'args',
schema: {
type: 'object',
properties: {
'focus': {
description: 'Controls if and when the hover should take focus upon being triggered by this action.',
enum: [HoverFocusBehavior.NoAutoFocus, HoverFocusBehavior.FocusIfVisible, HoverFocusBehavior.AutoFocusImmediately],
enumDescriptions: [
nls.localize('showOrFocusHover.focus.noAutoFocus', 'The hover will not automatically take focus.'),
nls.localize('showOrFocusHover.focus.focusIfVisible', 'The hover will take focus only if it is already visible.'),
nls.localize('showOrFocusHover.focus.autoFocusImmediately', 'The hover will automatically take focus when it appears.'),
],
default: HoverFocusBehavior.FocusIfVisible,
}
},
}
}]
},
alias: 'Show or Focus Hover',
precondition: undefined,
kbOpts: {
kbExpr: EditorContextKeys.editorTextFocus,
primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KeyK, KeyMod.CtrlCmd | KeyCode.KeyI),
weight: KeybindingWeight.EditorContrib
}
});
}
public run(accessor: ServicesAccessor, editor: ICodeEditor, args: any): void {
if (!editor.hasModel()) {
return;
}
const controller = HoverController.get(editor);
if (!controller) {
return;
}
const focusArgument = args?.focus;
let focusOption = HoverFocusBehavior.FocusIfVisible;
if (Object.values(HoverFocusBehavior).includes(focusArgument)) {
focusOption = focusArgument;
} else if (typeof focusArgument === 'boolean' && focusArgument) {
focusOption = HoverFocusBehavior.AutoFocusImmediately;
}
const showContentHover = (focus: boolean) => {
const position = editor.getPosition();
const range = new Range(position.lineNumber, position.column, position.lineNumber, position.column);
controller.showContentHover(range, HoverStartMode.Immediate, HoverStartSource.Keyboard, focus);
};
const accessibilitySupportEnabled = editor.getOption(EditorOption.accessibilitySupport) === AccessibilitySupport.Enabled;
if (controller.isHoverVisible) {
if (focusOption !== HoverFocusBehavior.NoAutoFocus) {
controller.focus();
} else {
showContentHover(accessibilitySupportEnabled);
}
} else {
showContentHover(accessibilitySupportEnabled || focusOption === HoverFocusBehavior.AutoFocusImmediately);
}
}
}
export class ShowDefinitionPreviewHoverAction extends EditorAction {
constructor() {
super({
id: 'editor.action.showDefinitionPreviewHover',
label: nls.localize({
key: 'showDefinitionPreviewHover',
comment: [
'Label for action that will trigger the showing of definition preview hover in the editor.',
'This allows for users to show the definition preview hover without using the mouse.'
]
}, "Show Definition Preview Hover"),
alias: 'Show Definition Preview Hover',
precondition: undefined,
metadata: {
description: nls.localize2('showDefinitionPreviewHoverDescription', 'Show the definition preview hover in the editor.'),
},
});
}
public run(accessor: ServicesAccessor, editor: ICodeEditor): void {
const controller = HoverController.get(editor);
if (!controller) {
return;
}
const position = editor.getPosition();
if (!position) {
return;
}
const range = new Range(position.lineNumber, position.column, position.lineNumber, position.column);
const goto = GotoDefinitionAtPositionEditorContribution.get(editor);
if (!goto) {
return;
}
const promise = goto.startFindDefinitionFromCursor(position);
promise.then(() => {
controller.showContentHover(range, HoverStartMode.Immediate, HoverStartSource.Keyboard, true);
});
}
}
export class ScrollUpHoverAction extends EditorAction {
constructor() {
super({
id: 'editor.action.scrollUpHover',
label: nls.localize({
key: 'scrollUpHover',
comment: [
'Action that allows to scroll up in the hover widget with the up arrow when the hover widget is focused.'
]
}, "Scroll Up Hover"),
alias: 'Scroll Up Hover',
precondition: EditorContextKeys.hoverFocused,
kbOpts: {
kbExpr: EditorContextKeys.hoverFocused,
primary: KeyCode.UpArrow,
weight: KeybindingWeight.EditorContrib
},
metadata: {
description: nls.localize2('scrollUpHoverDescription', 'Scroll up the editor hover.')
},
});
}
public run(accessor: ServicesAccessor, editor: ICodeEditor): void {
const controller = HoverController.get(editor);
if (!controller) {
return;
}
controller.scrollUp();
}
}
export class ScrollDownHoverAction extends EditorAction {
constructor() {
super({
id: 'editor.action.scrollDownHover',
label: nls.localize({
key: 'scrollDownHover',
comment: [
'Action that allows to scroll down in the hover widget with the up arrow when the hover widget is focused.'
]
}, "Scroll Down Hover"),
alias: 'Scroll Down Hover',
precondition: EditorContextKeys.hoverFocused,
kbOpts: {
kbExpr: EditorContextKeys.hoverFocused,
primary: KeyCode.DownArrow,
weight: KeybindingWeight.EditorContrib
},
metadata: {
description: nls.localize2('scrollDownHoverDescription', 'Scroll down the editor hover.'),
},
});
}
public run(accessor: ServicesAccessor, editor: ICodeEditor): void {
const controller = HoverController.get(editor);
if (!controller) {
return;
}
controller.scrollDown();
}
}
export class ScrollLeftHoverAction extends EditorAction {
constructor() {
super({
id: 'editor.action.scrollLeftHover',
label: nls.localize({
key: 'scrollLeftHover',
comment: [
'Action that allows to scroll left in the hover widget with the left arrow when the hover widget is focused.'
]
}, "Scroll Left Hover"),
alias: 'Scroll Left Hover',
precondition: EditorContextKeys.hoverFocused,
kbOpts: {
kbExpr: EditorContextKeys.hoverFocused,
primary: KeyCode.LeftArrow,
weight: KeybindingWeight.EditorContrib
},
metadata: {
description: nls.localize2('scrollLeftHoverDescription', 'Scroll left the editor hover.'),
},
});
}
public run(accessor: ServicesAccessor, editor: ICodeEditor): void {
const controller = HoverController.get(editor);
if (!controller) {
return;
}
controller.scrollLeft();
}
}
export class ScrollRightHoverAction extends EditorAction {
constructor() {
super({
id: 'editor.action.scrollRightHover',
label: nls.localize({
key: 'scrollRightHover',
comment: [
'Action that allows to scroll right in the hover widget with the right arrow when the hover widget is focused.'
]
}, "Scroll Right Hover"),
alias: 'Scroll Right Hover',
precondition: EditorContextKeys.hoverFocused,
kbOpts: {
kbExpr: EditorContextKeys.hoverFocused,
primary: KeyCode.RightArrow,
weight: KeybindingWeight.EditorContrib
},
metadata: {
description: nls.localize2('scrollRightHoverDescription', 'Scroll right the editor hover.')
},
});
}
public run(accessor: ServicesAccessor, editor: ICodeEditor): void {
const controller = HoverController.get(editor);
if (!controller) {
return;
}
controller.scrollRight();
}
}
export class PageUpHoverAction extends EditorAction {
constructor() {
super({
id: 'editor.action.pageUpHover',
label: nls.localize({
key: 'pageUpHover',
comment: [
'Action that allows to page up in the hover widget with the page up command when the hover widget is focused.'
]
}, "Page Up Hover"),
alias: 'Page Up Hover',
precondition: EditorContextKeys.hoverFocused,
kbOpts: {
kbExpr: EditorContextKeys.hoverFocused,
primary: KeyCode.PageUp,
secondary: [KeyMod.Alt | KeyCode.UpArrow],
weight: KeybindingWeight.EditorContrib
},
metadata: {
description: nls.localize2('pageUpHoverDescription', 'Page up the editor hover.'),
},
});
}
public run(accessor: ServicesAccessor, editor: ICodeEditor): void {
const controller = HoverController.get(editor);
if (!controller) {
return;
}
controller.pageUp();
}
}
export class PageDownHoverAction extends EditorAction {
constructor() {
super({
id: 'editor.action.pageDownHover',
label: nls.localize({
key: 'pageDownHover',
comment: [
'Action that allows to page down in the hover widget with the page down command when the hover widget is focused.'
]
}, "Page Down Hover"),
alias: 'Page Down Hover',
precondition: EditorContextKeys.hoverFocused,
kbOpts: {
kbExpr: EditorContextKeys.hoverFocused,
primary: KeyCode.PageDown,
secondary: [KeyMod.Alt | KeyCode.DownArrow],
weight: KeybindingWeight.EditorContrib
},
metadata: {
description: nls.localize2('pageDownHoverDescription', 'Page down the editor hover.'),
},
});
}
public run(accessor: ServicesAccessor, editor: ICodeEditor): void {
const controller = HoverController.get(editor);
if (!controller) {
return;
}
controller.pageDown();
}
}
export class GoToTopHoverAction extends EditorAction {
constructor() {
super({
id: 'editor.action.goToTopHover',
label: nls.localize({
key: 'goToTopHover',
comment: [
'Action that allows to go to the top of the hover widget with the home command when the hover widget is focused.'
]
}, "Go To Top Hover"),
alias: 'Go To Bottom Hover',
precondition: EditorContextKeys.hoverFocused,
kbOpts: {
kbExpr: EditorContextKeys.hoverFocused,
primary: KeyCode.Home,
secondary: [KeyMod.CtrlCmd | KeyCode.UpArrow],
weight: KeybindingWeight.EditorContrib
},
metadata: {
description: nls.localize2('goToTopHoverDescription', 'Go to the top of the editor hover.'),
},
});
}
public run(accessor: ServicesAccessor, editor: ICodeEditor): void {
const controller = HoverController.get(editor);
if (!controller) {
return;
}
controller.goToTop();
}
}
export class GoToBottomHoverAction extends EditorAction {
constructor() {
super({
id: 'editor.action.goToBottomHover',
label: nls.localize({
key: 'goToBottomHover',
comment: [
'Action that allows to go to the bottom in the hover widget with the end command when the hover widget is focused.'
]
}, "Go To Bottom Hover"),
alias: 'Go To Bottom Hover',
precondition: EditorContextKeys.hoverFocused,
kbOpts: {
kbExpr: EditorContextKeys.hoverFocused,
primary: KeyCode.End,
secondary: [KeyMod.CtrlCmd | KeyCode.DownArrow],
weight: KeybindingWeight.EditorContrib
},
metadata: {
description: nls.localize2('goToBottomHoverDescription', 'Go to the bottom of the editor hover.')
},
});
}
public run(accessor: ServicesAccessor, editor: ICodeEditor): void {
const controller = HoverController.get(editor);
if (!controller) {
return;
}
controller.goToBottom();
}
}
@@ -0,0 +1,38 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* 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 { EditorContributionInstantiation, registerEditorAction, registerEditorContribution } from 'vs/editor/browser/editorExtensions';
import { editorHoverBorder } from 'vs/platform/theme/common/colorRegistry';
import { registerThemingParticipant } from 'vs/platform/theme/common/themeService';
import { HoverParticipantRegistry } from 'vs/editor/contrib/hover/browser/hoverTypes';
import { MarkdownHoverParticipant } from 'vs/editor/contrib/hover/browser/markdownHoverParticipant';
import { MarkerHoverParticipant } from 'vs/editor/contrib/hover/browser/markerHoverParticipant';
import { HoverController } from 'vs/editor/contrib/hover/browser/hoverController';
import 'vs/css!./hover';
registerEditorContribution(HoverController.ID, HoverController, EditorContributionInstantiation.BeforeFirstInteraction);
registerEditorAction(ShowOrFocusHoverAction);
registerEditorAction(ShowDefinitionPreviewHoverAction);
registerEditorAction(ScrollUpHoverAction);
registerEditorAction(ScrollDownHoverAction);
registerEditorAction(ScrollLeftHoverAction);
registerEditorAction(ScrollRightHoverAction);
registerEditorAction(PageUpHoverAction);
registerEditorAction(PageDownHoverAction);
registerEditorAction(GoToTopHoverAction);
registerEditorAction(GoToBottomHoverAction);
HoverParticipantRegistry.register(MarkdownHoverParticipant);
HoverParticipantRegistry.register(MarkerHoverParticipant);
// theming
registerThemingParticipant((theme, collector) => {
const hoverBorder = theme.getColor(editorHoverBorder);
if (hoverBorder) {
collector.addRule(`.monaco-editor .monaco-hover .hover-row:not(:first-child):not(:empty) { border-top: 1px solid ${hoverBorder.transparent(0.5)}; }`);
collector.addRule(`.monaco-editor .monaco-hover hr { border-top: 1px solid ${hoverBorder.transparent(0.5)}; }`);
collector.addRule(`.monaco-editor .monaco-hover hr { border-bottom: 0px solid ${hoverBorder.transparent(0.5)}; }`);
}
});
@@ -4,31 +4,21 @@
*--------------------------------------------------------------------------------------------*/
import { IKeyboardEvent } from 'vs/base/browser/keyboardEvent';
import { KeyChord, KeyCode, KeyMod } from 'vs/base/common/keyCodes';
import { KeyCode } from 'vs/base/common/keyCodes';
import { Disposable, DisposableStore } from 'vs/base/common/lifecycle';
import { ICodeEditor, IEditorMouseEvent, IPartialEditorMouseEvent, MouseTargetType } from 'vs/editor/browser/editorBrowser';
import { EditorAction, EditorContributionInstantiation, registerEditorAction, registerEditorContribution, ServicesAccessor } from 'vs/editor/browser/editorExtensions';
import { ConfigurationChangedEvent, EditorOption } from 'vs/editor/common/config/editorOptions';
import { Range } from 'vs/editor/common/core/range';
import { IEditorContribution, IScrollEvent } from 'vs/editor/common/editorCommon';
import { EditorContextKeys } from 'vs/editor/common/editorContextKeys';
import { GotoDefinitionAtPositionEditorContribution } from 'vs/editor/contrib/gotoSymbol/browser/link/goToDefinitionAtPosition';
import { HoverStartMode, HoverStartSource } from 'vs/editor/contrib/hover/browser/hoverOperation';
import { ContentHoverWidget, ContentHoverController } from 'vs/editor/contrib/hover/browser/contentHover';
import { MarginHoverWidget } from 'vs/editor/contrib/hover/browser/marginHover';
import { AccessibilitySupport } from 'vs/platform/accessibility/common/accessibility';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry';
import { editorHoverBorder } from 'vs/platform/theme/common/colorRegistry';
import { registerThemingParticipant } from 'vs/platform/theme/common/themeService';
import { HoverParticipantRegistry, IHoverWidget } from 'vs/editor/contrib/hover/browser/hoverTypes';
import { MarkdownHoverParticipant } from 'vs/editor/contrib/hover/browser/markdownHoverParticipant';
import { MarkerHoverParticipant } from 'vs/editor/contrib/hover/browser/markerHoverParticipant';
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 { RunOnceScheduler } from 'vs/base/common/async';
import * as nls from 'vs/nls';
import 'vs/css!./hover';
// sticky hover widget which doesn't disappear on focus out and such
@@ -465,429 +455,3 @@ export class HoverController extends Disposable implements IEditorContribution {
this._contentWidget?.dispose();
}
}
enum HoverFocusBehavior {
NoAutoFocus = 'noAutoFocus',
FocusIfVisible = 'focusIfVisible',
AutoFocusImmediately = 'autoFocusImmediately'
}
class ShowOrFocusHoverAction extends EditorAction {
constructor() {
super({
id: 'editor.action.showHover',
label: nls.localize({
key: 'showOrFocusHover',
comment: [
'Label for action that will trigger the showing/focusing of a hover in the editor.',
'If the hover is not visible, it will show the hover.',
'This allows for users to show the hover without using the mouse.'
]
}, "Show or Focus Hover"),
metadata: {
description: nls.localize2('showOrFocusHoverDescription', 'Show or focus the editor hover which shows documentation, references, and other content for a symbol at the current cursor position.'),
args: [{
name: 'args',
schema: {
type: 'object',
properties: {
'focus': {
description: 'Controls if and when the hover should take focus upon being triggered by this action.',
enum: [HoverFocusBehavior.NoAutoFocus, HoverFocusBehavior.FocusIfVisible, HoverFocusBehavior.AutoFocusImmediately],
enumDescriptions: [
nls.localize('showOrFocusHover.focus.noAutoFocus', 'The hover will not automatically take focus.'),
nls.localize('showOrFocusHover.focus.focusIfVisible', 'The hover will take focus only if it is already visible.'),
nls.localize('showOrFocusHover.focus.autoFocusImmediately', 'The hover will automatically take focus when it appears.'),
],
default: HoverFocusBehavior.FocusIfVisible,
}
},
}
}]
},
alias: 'Show or Focus Hover',
precondition: undefined,
kbOpts: {
kbExpr: EditorContextKeys.editorTextFocus,
primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KeyK, KeyMod.CtrlCmd | KeyCode.KeyI),
weight: KeybindingWeight.EditorContrib
}
});
}
public run(accessor: ServicesAccessor, editor: ICodeEditor, args: any): void {
if (!editor.hasModel()) {
return;
}
const controller = HoverController.get(editor);
if (!controller) {
return;
}
const focusArgument = args?.focus;
let focusOption = HoverFocusBehavior.FocusIfVisible;
if (Object.values(HoverFocusBehavior).includes(focusArgument)) {
focusOption = focusArgument;
} else if (typeof focusArgument === 'boolean' && focusArgument) {
focusOption = HoverFocusBehavior.AutoFocusImmediately;
}
const showContentHover = (focus: boolean) => {
const position = editor.getPosition();
const range = new Range(position.lineNumber, position.column, position.lineNumber, position.column);
controller.showContentHover(range, HoverStartMode.Immediate, HoverStartSource.Keyboard, focus);
};
const accessibilitySupportEnabled = editor.getOption(EditorOption.accessibilitySupport) === AccessibilitySupport.Enabled;
if (controller.isHoverVisible) {
if (focusOption !== HoverFocusBehavior.NoAutoFocus) {
controller.focus();
} else {
showContentHover(accessibilitySupportEnabled);
}
} else {
showContentHover(accessibilitySupportEnabled || focusOption === HoverFocusBehavior.AutoFocusImmediately);
}
}
}
class ShowDefinitionPreviewHoverAction extends EditorAction {
constructor() {
super({
id: 'editor.action.showDefinitionPreviewHover',
label: nls.localize({
key: 'showDefinitionPreviewHover',
comment: [
'Label for action that will trigger the showing of definition preview hover in the editor.',
'This allows for users to show the definition preview hover without using the mouse.'
]
}, "Show Definition Preview Hover"),
alias: 'Show Definition Preview Hover',
precondition: undefined,
metadata: {
description: nls.localize2('showDefinitionPreviewHoverDescription', 'Show the definition preview hover in the editor.'),
},
});
}
public run(accessor: ServicesAccessor, editor: ICodeEditor): void {
const controller = HoverController.get(editor);
if (!controller) {
return;
}
const position = editor.getPosition();
if (!position) {
return;
}
const range = new Range(position.lineNumber, position.column, position.lineNumber, position.column);
const goto = GotoDefinitionAtPositionEditorContribution.get(editor);
if (!goto) {
return;
}
const promise = goto.startFindDefinitionFromCursor(position);
promise.then(() => {
controller.showContentHover(range, HoverStartMode.Immediate, HoverStartSource.Keyboard, true);
});
}
}
class ScrollUpHoverAction extends EditorAction {
constructor() {
super({
id: 'editor.action.scrollUpHover',
label: nls.localize({
key: 'scrollUpHover',
comment: [
'Action that allows to scroll up in the hover widget with the up arrow when the hover widget is focused.'
]
}, "Scroll Up Hover"),
alias: 'Scroll Up Hover',
precondition: EditorContextKeys.hoverFocused,
kbOpts: {
kbExpr: EditorContextKeys.hoverFocused,
primary: KeyCode.UpArrow,
weight: KeybindingWeight.EditorContrib
},
metadata: {
description: nls.localize2('scrollUpHoverDescription', 'Scroll up the editor hover.')
},
});
}
public run(accessor: ServicesAccessor, editor: ICodeEditor): void {
const controller = HoverController.get(editor);
if (!controller) {
return;
}
controller.scrollUp();
}
}
class ScrollDownHoverAction extends EditorAction {
constructor() {
super({
id: 'editor.action.scrollDownHover',
label: nls.localize({
key: 'scrollDownHover',
comment: [
'Action that allows to scroll down in the hover widget with the up arrow when the hover widget is focused.'
]
}, "Scroll Down Hover"),
alias: 'Scroll Down Hover',
precondition: EditorContextKeys.hoverFocused,
kbOpts: {
kbExpr: EditorContextKeys.hoverFocused,
primary: KeyCode.DownArrow,
weight: KeybindingWeight.EditorContrib
},
metadata: {
description: nls.localize2('scrollDownHoverDescription', 'Scroll down the editor hover.'),
},
});
}
public run(accessor: ServicesAccessor, editor: ICodeEditor): void {
const controller = HoverController.get(editor);
if (!controller) {
return;
}
controller.scrollDown();
}
}
class ScrollLeftHoverAction extends EditorAction {
constructor() {
super({
id: 'editor.action.scrollLeftHover',
label: nls.localize({
key: 'scrollLeftHover',
comment: [
'Action that allows to scroll left in the hover widget with the left arrow when the hover widget is focused.'
]
}, "Scroll Left Hover"),
alias: 'Scroll Left Hover',
precondition: EditorContextKeys.hoverFocused,
kbOpts: {
kbExpr: EditorContextKeys.hoverFocused,
primary: KeyCode.LeftArrow,
weight: KeybindingWeight.EditorContrib
},
metadata: {
description: nls.localize2('scrollLeftHoverDescription', 'Scroll left the editor hover.'),
},
});
}
public run(accessor: ServicesAccessor, editor: ICodeEditor): void {
const controller = HoverController.get(editor);
if (!controller) {
return;
}
controller.scrollLeft();
}
}
class ScrollRightHoverAction extends EditorAction {
constructor() {
super({
id: 'editor.action.scrollRightHover',
label: nls.localize({
key: 'scrollRightHover',
comment: [
'Action that allows to scroll right in the hover widget with the right arrow when the hover widget is focused.'
]
}, "Scroll Right Hover"),
alias: 'Scroll Right Hover',
precondition: EditorContextKeys.hoverFocused,
kbOpts: {
kbExpr: EditorContextKeys.hoverFocused,
primary: KeyCode.RightArrow,
weight: KeybindingWeight.EditorContrib
},
metadata: {
description: nls.localize2('scrollRightHoverDescription', 'Scroll right the editor hover.')
},
});
}
public run(accessor: ServicesAccessor, editor: ICodeEditor): void {
const controller = HoverController.get(editor);
if (!controller) {
return;
}
controller.scrollRight();
}
}
class PageUpHoverAction extends EditorAction {
constructor() {
super({
id: 'editor.action.pageUpHover',
label: nls.localize({
key: 'pageUpHover',
comment: [
'Action that allows to page up in the hover widget with the page up command when the hover widget is focused.'
]
}, "Page Up Hover"),
alias: 'Page Up Hover',
precondition: EditorContextKeys.hoverFocused,
kbOpts: {
kbExpr: EditorContextKeys.hoverFocused,
primary: KeyCode.PageUp,
secondary: [KeyMod.Alt | KeyCode.UpArrow],
weight: KeybindingWeight.EditorContrib
},
metadata: {
description: nls.localize2('pageUpHoverDescription', 'Page up the editor hover.'),
},
});
}
public run(accessor: ServicesAccessor, editor: ICodeEditor): void {
const controller = HoverController.get(editor);
if (!controller) {
return;
}
controller.pageUp();
}
}
class PageDownHoverAction extends EditorAction {
constructor() {
super({
id: 'editor.action.pageDownHover',
label: nls.localize({
key: 'pageDownHover',
comment: [
'Action that allows to page down in the hover widget with the page down command when the hover widget is focused.'
]
}, "Page Down Hover"),
alias: 'Page Down Hover',
precondition: EditorContextKeys.hoverFocused,
kbOpts: {
kbExpr: EditorContextKeys.hoverFocused,
primary: KeyCode.PageDown,
secondary: [KeyMod.Alt | KeyCode.DownArrow],
weight: KeybindingWeight.EditorContrib
},
metadata: {
description: nls.localize2('pageDownHoverDescription', 'Page down the editor hover.'),
},
});
}
public run(accessor: ServicesAccessor, editor: ICodeEditor): void {
const controller = HoverController.get(editor);
if (!controller) {
return;
}
controller.pageDown();
}
}
class GoToTopHoverAction extends EditorAction {
constructor() {
super({
id: 'editor.action.goToTopHover',
label: nls.localize({
key: 'goToTopHover',
comment: [
'Action that allows to go to the top of the hover widget with the home command when the hover widget is focused.'
]
}, "Go To Top Hover"),
alias: 'Go To Bottom Hover',
precondition: EditorContextKeys.hoverFocused,
kbOpts: {
kbExpr: EditorContextKeys.hoverFocused,
primary: KeyCode.Home,
secondary: [KeyMod.CtrlCmd | KeyCode.UpArrow],
weight: KeybindingWeight.EditorContrib
},
metadata: {
description: nls.localize2('goToTopHoverDescription', 'Go to the top of the editor hover.'),
},
});
}
public run(accessor: ServicesAccessor, editor: ICodeEditor): void {
const controller = HoverController.get(editor);
if (!controller) {
return;
}
controller.goToTop();
}
}
class GoToBottomHoverAction extends EditorAction {
constructor() {
super({
id: 'editor.action.goToBottomHover',
label: nls.localize({
key: 'goToBottomHover',
comment: [
'Action that allows to go to the bottom in the hover widget with the end command when the hover widget is focused.'
]
}, "Go To Bottom Hover"),
alias: 'Go To Bottom Hover',
precondition: EditorContextKeys.hoverFocused,
kbOpts: {
kbExpr: EditorContextKeys.hoverFocused,
primary: KeyCode.End,
secondary: [KeyMod.CtrlCmd | KeyCode.DownArrow],
weight: KeybindingWeight.EditorContrib
},
metadata: {
description: nls.localize2('goToBottomHoverDescription', 'Go to the bottom of the editor hover.')
},
});
}
public run(accessor: ServicesAccessor, editor: ICodeEditor): void {
const controller = HoverController.get(editor);
if (!controller) {
return;
}
controller.goToBottom();
}
}
registerEditorContribution(HoverController.ID, HoverController, EditorContributionInstantiation.BeforeFirstInteraction);
registerEditorAction(ShowOrFocusHoverAction);
registerEditorAction(ShowDefinitionPreviewHoverAction);
registerEditorAction(ScrollUpHoverAction);
registerEditorAction(ScrollDownHoverAction);
registerEditorAction(ScrollLeftHoverAction);
registerEditorAction(ScrollRightHoverAction);
registerEditorAction(PageUpHoverAction);
registerEditorAction(PageDownHoverAction);
registerEditorAction(GoToTopHoverAction);
registerEditorAction(GoToBottomHoverAction);
HoverParticipantRegistry.register(MarkdownHoverParticipant);
HoverParticipantRegistry.register(MarkerHoverParticipant);
// theming
registerThemingParticipant((theme, collector) => {
const hoverBorder = theme.getColor(editorHoverBorder);
if (hoverBorder) {
collector.addRule(`.monaco-editor .monaco-hover .hover-row:not(:first-child):not(:empty) { border-top: 1px solid ${hoverBorder.transparent(0.5)}; }`);
collector.addRule(`.monaco-editor .monaco-hover hr { border-top: 1px solid ${hoverBorder.transparent(0.5)}; }`);
collector.addRule(`.monaco-editor .monaco-hover hr { border-bottom: 0px solid ${hoverBorder.transparent(0.5)}; }`);
}
});
@@ -308,7 +308,6 @@ class StickyModelFromCandidateOutlineProvider extends StickyModelCandidateProvid
return res;
}
}
}
abstract class StickyModelFromCandidateFoldingProvider extends StickyModelCandidateProvider<FoldingRegions | null> {
+1 -1
View File
@@ -31,7 +31,7 @@ import 'vs/editor/contrib/inlineProgress/browser/inlineProgress';
import 'vs/editor/contrib/gotoSymbol/browser/goToCommands';
import 'vs/editor/contrib/gotoSymbol/browser/link/goToDefinitionAtPosition';
import 'vs/editor/contrib/gotoError/browser/gotoError';
import 'vs/editor/contrib/hover/browser/hover';
import 'vs/editor/contrib/hover/browser/hoverContribution';
import 'vs/editor/contrib/indentation/browser/indentation';
import 'vs/editor/contrib/inlayHints/browser/inlayHintsContribution';
import 'vs/editor/contrib/inPlaceReplace/browser/inPlaceReplace';
@@ -15,7 +15,6 @@ import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { AccessibilityVerbositySettingId, AccessibleViewProviderId, accessibleViewIsShown } from 'vs/workbench/contrib/accessibility/browser/accessibilityConfiguration';
import * as strings from 'vs/base/common/strings';
import { ICommandService } from 'vs/platform/commands/common/commands';
import { HoverController } from 'vs/editor/contrib/hover/browser/hover';
import { IContextViewService } from 'vs/platform/contextview/browser/contextView';
import { EditorContextKeys } from 'vs/editor/common/editorContextKeys';
import { getNotificationFromContext } from 'vs/workbench/browser/parts/notifications/notificationsCommands';
@@ -33,6 +32,7 @@ import { InlineCompletionsController } from 'vs/editor/contrib/inlineCompletions
import { InlineCompletionContextKeys } from 'vs/editor/contrib/inlineCompletions/browser/inlineCompletionContextKeys';
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
import { AccessibilitySignal, IAccessibilitySignalService } from 'vs/platform/accessibilitySignal/browser/accessibilitySignalService';
import { HoverController } from 'vs/editor/contrib/hover/browser/hoverController';
export function descriptionForCommand(commandId: string, msg: string, noKbMsg: string, keybindingService: IKeybindingService): string {
const kb = keybindingService.lookupKeybinding(commandId);
@@ -22,7 +22,7 @@ import { IDimension } from 'vs/editor/common/core/dimension';
import { IPosition } from 'vs/editor/common/core/position';
import { ITextModel } from 'vs/editor/common/model';
import { IModelService } from 'vs/editor/common/services/model';
import { HoverController } from 'vs/editor/contrib/hover/browser/hover';
import { HoverController } from 'vs/editor/contrib/hover/browser/hoverController';
import { localize } from 'vs/nls';
import { IAccessibilityService } from 'vs/platform/accessibility/common/accessibility';
import { DropdownWithPrimaryActionViewItem } from 'vs/platform/actions/browser/dropdownWithPrimaryActionViewItem';
@@ -24,7 +24,6 @@ import { IResolvedTextEditorModel, ITextModelContentProvider, ITextModelService
import { BracketMatchingController } from 'vs/editor/contrib/bracketMatching/browser/bracketMatching';
import { ContextMenuController } from 'vs/editor/contrib/contextmenu/browser/contextmenu';
import { GotoDefinitionAtPositionEditorContribution } from 'vs/editor/contrib/gotoSymbol/browser/link/goToDefinitionAtPosition';
import { HoverController } from 'vs/editor/contrib/hover/browser/hover';
import { ViewportSemanticTokensContribution } from 'vs/editor/contrib/semanticTokens/browser/viewportSemanticTokens';
import { SmartSelectController } from 'vs/editor/contrib/smartSelect/browser/smartSelect';
import { WordHighlighterContribution } from 'vs/editor/contrib/wordHighlighter/browser/wordHighlighter';
@@ -50,6 +49,7 @@ import { ChatTreeItem } from 'vs/workbench/contrib/chat/browser/chat';
import { TextEdit } from 'vs/editor/common/languages';
import { CancellationToken } from 'vs/base/common/cancellation';
import { IDiffEditor } from 'vs/editor/browser/editorBrowser';
import { HoverController } from 'vs/editor/contrib/hover/browser/hoverController';
const $ = dom.$;
@@ -31,12 +31,12 @@ import { clamp } from 'vs/base/common/numbers';
import { CopyPasteController } from 'vs/editor/contrib/dropOrPasteInto/browser/copyPasteController';
import { CodeActionController } from 'vs/editor/contrib/codeAction/browser/codeActionController';
import { DropIntoEditorController } from 'vs/editor/contrib/dropOrPasteInto/browser/dropIntoEditorController';
import { HoverController } from 'vs/editor/contrib/hover/browser/hover';
import { InlineCompletionsController } from 'vs/editor/contrib/inlineCompletions/browser/inlineCompletionsController';
import { LinkDetector } from 'vs/editor/contrib/links/browser/links';
import { MessageController } from 'vs/editor/contrib/message/browser/messageController';
import { SelectionClipboardContributionID } from 'vs/workbench/contrib/codeEditor/browser/selectionClipboard';
import { MenuId } from 'vs/platform/actions/common/actions';
import { HoverController } from 'vs/editor/contrib/hover/browser/hoverController';
export const ctxCommentEditorFocused = new RawContextKey<boolean>('commentEditorFocused', false);
export const MIN_EDITOR_HEIGHT = 5 * 18;
@@ -36,7 +36,7 @@ import { IModelDeltaDecoration, ITextModel, InjectedTextCursorStops } from 'vs/e
import { IFeatureDebounceInformation, ILanguageFeatureDebounceService } from 'vs/editor/common/services/languageFeatureDebounce';
import { ILanguageFeaturesService } from 'vs/editor/common/services/languageFeatures';
import { IModelService } from 'vs/editor/common/services/model';
import { HoverController } from 'vs/editor/contrib/hover/browser/hover';
import { HoverController } from 'vs/editor/contrib/hover/browser/hoverController';
import { HoverStartMode, HoverStartSource } from 'vs/editor/contrib/hover/browser/hoverOperation';
import * as nls from 'vs/nls';
import { CommandsRegistry, ICommandService } from 'vs/platform/commands/common/commands';
@@ -48,7 +48,6 @@ import { ContextMenuController } from 'vs/editor/contrib/contextmenu/browser/con
import { SuggestController } from 'vs/editor/contrib/suggest/browser/suggestController';
import { SnippetController2 } from 'vs/editor/contrib/snippet/browser/snippetController2';
import { TabCompletionController } from 'vs/workbench/contrib/snippets/browser/tabCompletion';
import { HoverController } from 'vs/editor/contrib/hover/browser/hover';
import { MarkerController } from 'vs/editor/contrib/gotoError/browser/gotoError';
import { EditorInput } from 'vs/workbench/common/editor/editorInput';
import { ITextResourceConfigurationService } from 'vs/editor/common/services/textResourceConfiguration';
@@ -63,6 +62,7 @@ import { INTERACTIVE_WINDOW_EDITOR_ID } from 'vs/workbench/contrib/notebook/comm
import 'vs/css!./interactiveEditor';
import { IEditorOptions } from 'vs/editor/common/config/editorOptions';
import { deepClone } from 'vs/base/common/objects';
import { HoverController } from 'vs/editor/contrib/hover/browser/hoverController';
const DECORATION_KEY = 'interactiveInputDecoration';
const INTERACTIVE_EDITOR_VIEW_STATE_PREFERENCE_KEY = 'InteractiveEditorViewState';
@@ -58,7 +58,6 @@ import { compare, format } from 'vs/base/common/strings';
import { SuggestController } from 'vs/editor/contrib/suggest/browser/suggestController';
import { SnippetController2 } from 'vs/editor/contrib/snippet/browser/snippetController2';
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
import { HoverController } from 'vs/editor/contrib/hover/browser/hover';
import { ColorDetector } from 'vs/editor/contrib/colorPicker/browser/colorDetector';
import { LinkDetector } from 'vs/editor/contrib/links/browser/links';
import { IOpenerService } from 'vs/platform/opener/common/opener';
@@ -112,6 +111,7 @@ import { MarkdownString } from 'vs/base/common/htmlContent';
import type { IUpdatableHover, IUpdatableHoverTooltipMarkdownString } from 'vs/base/browser/ui/hover/hover';
import { IHoverService } from 'vs/platform/hover/browser/hover';
import { OpenScmGroupAction } from 'vs/workbench/contrib/multiDiffEditor/browser/scmMultiDiffSourceResolver';
import { HoverController } from 'vs/editor/contrib/hover/browser/hoverController';
// type SCMResourceTreeNode = IResourceNode<ISCMResource, ISCMResourceGroup>;
// type SCMHistoryItemChangeResourceTreeNode = IResourceNode<SCMHistoryItemChangeTreeElement, SCMHistoryItemTreeElement>;