提交 291c8e58 编写于 作者: A Alex Dima

Allow editor.hover to be an object

上级 f3159128
......@@ -294,6 +294,11 @@ const editorConfiguration: IConfigurationNode = {
'default': EDITOR_DEFAULTS.viewInfo.minimap.maxColumn,
'description': nls.localize('minimap.maxColumn', "Limit the width of the minimap to render at most a certain number of columns")
},
'editor.hover.enabled': {
'type': 'boolean',
'default': EDITOR_DEFAULTS.contribInfo.hover.enabled,
'description': nls.localize('hover.enabled', "Controls if the hover is shown")
},
'editor.find.seedSearchStringFromSelection': {
'type': 'boolean',
'default': EDITOR_DEFAULTS.contribInfo.find.seedSearchStringFromSelection,
......
......@@ -137,6 +137,17 @@ export interface IEditorLightbulbOptions {
enabled?: boolean;
}
/**
* Configuration options for editor hover
*/
export interface IEditorHoverOptions {
/**
* Enable the hover.
* Defaults to true.
*/
enabled?: boolean;
}
/**
* Configuration map for codeActionsOnSave
*/
......@@ -367,10 +378,9 @@ export interface IEditorOptions {
*/
stopRenderingLineAfter?: number;
/**
* Enable hover.
* Defaults to true.
* Configure the editor's hover.
*/
hover?: boolean;
hover?: boolean | IEditorHoverOptions;
/**
* Enable detecting links and making them clickable.
* Defaults to true.
......@@ -804,6 +814,10 @@ export interface InternalEditorFindOptions {
readonly globalFindClipboard: boolean;
}
export interface InternalEditorHoverOptions {
readonly enabled: boolean;
}
export interface EditorWrappingInfo {
readonly inDiffEditor: boolean;
readonly isDominatedByLongLines: boolean;
......@@ -859,7 +873,7 @@ export interface InternalEditorViewOptions {
export interface EditorContribOptions {
readonly selectionClipboard: boolean;
readonly hover: boolean;
readonly hover: InternalEditorHoverOptions;
readonly links: boolean;
readonly contextmenu: boolean;
readonly quickSuggestions: boolean | { other: boolean, comments: boolean, strings: boolean };
......@@ -1181,7 +1195,6 @@ export class InternalEditorOptions {
/**
* @internal
*/
private static _equalFindOptions(a: InternalEditorFindOptions, b: InternalEditorFindOptions): boolean {
return (
a.seedSearchStringFromSelection === b.seedSearchStringFromSelection
......@@ -1190,6 +1203,15 @@ export class InternalEditorOptions {
);
}
/**
* @internal
*/
private static _equalsHoverOptions(a: InternalEditorHoverOptions, b: InternalEditorHoverOptions): boolean {
return (
a.enabled === b.enabled
);
}
/**
* @internal
*/
......@@ -1213,7 +1235,7 @@ export class InternalEditorOptions {
private static _equalsContribOptions(a: EditorContribOptions, b: EditorContribOptions): boolean {
return (
a.selectionClipboard === b.selectionClipboard
&& a.hover === b.hover
&& this._equalsHoverOptions(a.hover, b.hover)
&& a.links === b.links
&& a.contextmenu === b.contextmenu
&& InternalEditorOptions._equalsQuickSuggestions(a.quickSuggestions, b.quickSuggestions)
......@@ -1659,6 +1681,23 @@ export class EditorOptionsValidator {
};
}
private static _santizeHoverOpts(_opts: boolean | IEditorHoverOptions, defaults: InternalEditorHoverOptions): InternalEditorHoverOptions {
let opts: IEditorHoverOptions;
if (typeof _opts === 'boolean') {
opts = {
enabled: _opts
};
} else if (typeof _opts === 'object') {
opts = _opts;
} else {
return defaults;
}
return {
enabled: _boolean(opts.enabled, defaults.enabled)
};
}
private static _sanitizeViewInfo(opts: IEditorOptions, defaults: InternalEditorViewOptions): InternalEditorViewOptions {
let rulers: number[] = [];
......@@ -1777,7 +1816,7 @@ export class EditorOptionsValidator {
const find = this._santizeFindOpts(opts.find, defaults.find);
return {
selectionClipboard: _boolean(opts.selectionClipboard, defaults.selectionClipboard),
hover: _boolean(opts.hover, defaults.hover),
hover: this._santizeHoverOpts(opts.hover, defaults.hover),
links: _boolean(opts.links, defaults.links),
contextmenu: _boolean(opts.contextmenu, defaults.contextmenu),
quickSuggestions: quickSuggestions,
......@@ -2352,7 +2391,9 @@ export const EDITOR_DEFAULTS: IValidatedEditorOptions = {
contribInfo: {
selectionClipboard: true,
hover: true,
hover: {
enabled: true
},
links: true,
contextmenu: true,
quickSuggestions: { other: true, comments: false, strings: false },
......
......@@ -2487,6 +2487,17 @@ declare namespace monaco.editor {
enabled?: boolean;
}
/**
* Configuration options for editor hover
*/
export interface IEditorHoverOptions {
/**
* Enable the hover.
* Defaults to true.
*/
enabled?: boolean;
}
/**
* Configuration map for codeActionsOnSave
*/
......@@ -2705,10 +2716,9 @@ declare namespace monaco.editor {
*/
stopRenderingLineAfter?: number;
/**
* Enable hover.
* Defaults to true.
* Configure the editor's hover.
*/
hover?: boolean;
hover?: boolean | IEditorHoverOptions;
/**
* Enable detecting links and making them clickable.
* Defaults to true.
......@@ -3083,6 +3093,10 @@ declare namespace monaco.editor {
readonly autoFindInSelection: boolean;
}
export interface InternalEditorHoverOptions {
readonly enabled: boolean;
}
export interface EditorWrappingInfo {
readonly inDiffEditor: boolean;
readonly isDominatedByLongLines: boolean;
......@@ -3138,7 +3152,7 @@ declare namespace monaco.editor {
export interface EditorContribOptions {
readonly selectionClipboard: boolean;
readonly hover: boolean;
readonly hover: InternalEditorHoverOptions;
readonly links: boolean;
readonly contextmenu: boolean;
readonly quickSuggestions: boolean | {
......
......@@ -21,12 +21,12 @@ import { DEFAULT_WORD_REGEXP } from 'vs/editor/common/model/wordHelper';
import { ICodeEditor, IEditorMouseEvent, MouseTargetType } from 'vs/editor/browser/editorBrowser';
import { registerEditorContribution } from 'vs/editor/browser/editorExtensions';
import { IDecorationOptions } from 'vs/editor/common/editorCommon';
import { IModelDecorationOptions, IModelDeltaDecoration, TrackedRangeStickiness } from 'vs/editor/common/model';
import { IModelDecorationOptions, IModelDeltaDecoration, TrackedRangeStickiness, ITextModel } from 'vs/editor/common/model';
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService';
import { Range } from 'vs/editor/common/core/range';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IConfigurationService, IConfigurationOverrides } from 'vs/platform/configuration/common/configuration';
import { ICommandService } from 'vs/platform/commands/common/commands';
import { IContextKeyService, IContextKey } from 'vs/platform/contextkey/common/contextkey';
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
......@@ -262,7 +262,7 @@ export class DebugEditorContribution implements IDebugEditorContribution {
this.toDispose.push(this.editor.onDidChangeModel(() => {
const stackFrame = this.debugService.getViewModel().focusedStackFrame;
const model = this.editor.getModel();
this.editor.updateOptions({ hover: !stackFrame || !model || model.uri.toString() !== stackFrame.source.uri.toString() });
this._applyHoverConfiguration(model, stackFrame);
this.closeBreakpointWidget();
this.toggleExceptionWidget();
this.hideHoverWidget();
......@@ -278,6 +278,26 @@ export class DebugEditorContribution implements IDebugEditorContribution {
}));
}
private _applyHoverConfiguration(model: ITextModel, stackFrame: IStackFrame): void {
if (stackFrame && model && model.uri.toString() === stackFrame.source.uri.toString()) {
this.editor.updateOptions({
hover: !stackFrame || !model || model.uri.toString() !== stackFrame.source.uri.toString()
});
} else {
let overrides: IConfigurationOverrides;
if (model) {
overrides = {
resource: model.uri,
overrideIdentifier: model.getLanguageIdentifier().language
};
}
const defaultConfiguration = this.configurationService.getValue('editor.hover', overrides);
this.editor.updateOptions({
hover: defaultConfiguration
});
}
}
public getId(): string {
return EDITOR_CONTRIBUTION_ID;
}
......@@ -323,11 +343,10 @@ export class DebugEditorContribution implements IDebugEditorContribution {
private onFocusStackFrame(sf: IStackFrame): void {
const model = this.editor.getModel();
this._applyHoverConfiguration(model, sf);
if (model && sf && sf.source.uri.toString() === model.uri.toString()) {
this.editor.updateOptions({ hover: false });
this.toggleExceptionWidget();
} else {
this.editor.updateOptions({ hover: true });
this.hideHoverWidget();
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册