提交 60211895 编写于 作者: J Joao Moreno

fixes #2465

上级 6c0b455f
......@@ -312,6 +312,8 @@ class InternalEditorOptionsHelper {
snippetSuggestions: opts.snippetSuggestions,
tabCompletion: opts.tabCompletion,
wordBasedSuggestions: opts.wordBasedSuggestions,
suggestFontSize: opts.suggestFontSize,
suggestLineHeight: opts.suggestLineHeight,
selectionHighlight: toBoolean(opts.selectionHighlight),
codeLens: opts.referenceInfos && opts.codeLens,
folding: toBoolean(opts.folding),
......@@ -765,6 +767,18 @@ let editorConfiguration:IConfigurationNode = {
'default': DefaultConfig.editor.wordBasedSuggestions,
'description': nls.localize('wordBasedSuggestions', "Enable word based suggestions.")
},
'editor.suggestFontSize' : {
'type': 'integer',
'default': 0,
'minimum': 0,
'description': nls.localize('suggestFontSize', "Font size for the suggest widget")
},
'editor.suggestLineHeight' : {
'type': 'integer',
'default': 0,
'minimum': 0,
'description': nls.localize('suggestLineHeight', "Line height for the suggest widget")
},
'editor.tabCompletion': {
'type': 'boolean',
'default': DefaultConfig.editor.tabCompletion,
......
......@@ -87,6 +87,8 @@ class ConfigClass implements IConfiguration {
snippetSuggestions: 'bottom',
tabCompletion: false,
wordBasedSuggestions: true,
suggestFontSize: 0,
suggestLineHeight: 0,
selectionHighlight: true,
codeLens: true,
referenceInfos: true,
......
......@@ -410,6 +410,16 @@ export interface IEditorOptions {
* Enable word based suggestions. Defaults to 'true'
*/
wordBasedSuggestions?: boolean;
/**
* The font size for the suggest widget.
* Defaults to the editor font size.
*/
suggestFontSize?: number;
/**
* The line height for the suggest widget.
* Defaults to the editor line height.
*/
suggestLineHeight?: number;
/**
* Enable selection highlight.
* Defaults to true.
......@@ -854,6 +864,8 @@ export class EditorContribOptions {
snippetSuggestions: 'top' | 'bottom' | 'inline' | 'none';
tabCompletion: boolean;
wordBasedSuggestions: boolean;
suggestFontSize: number;
suggestLineHeight: number;
selectionHighlight:boolean;
codeLens: boolean;
folding: boolean;
......@@ -875,6 +887,8 @@ export class EditorContribOptions {
snippetSuggestions: 'top' | 'bottom' | 'inline' | 'none';
tabCompletion: boolean;
wordBasedSuggestions: boolean;
suggestFontSize: number;
suggestLineHeight: number;
selectionHighlight:boolean;
codeLens: boolean;
folding: boolean;
......@@ -892,6 +906,8 @@ export class EditorContribOptions {
this.snippetSuggestions = source.snippetSuggestions;
this.tabCompletion = source.tabCompletion;
this.wordBasedSuggestions = source.wordBasedSuggestions;
this.suggestFontSize = source.suggestFontSize;
this.suggestLineHeight = source.suggestLineHeight;
this.selectionHighlight = Boolean(source.selectionHighlight);
this.codeLens = Boolean(source.codeLens);
this.folding = Boolean(source.folding);
......@@ -915,6 +931,8 @@ export class EditorContribOptions {
&& this.snippetSuggestions === other.snippetSuggestions
&& this.tabCompletion === other.tabCompletion
&& this.wordBasedSuggestions === other.wordBasedSuggestions
&& this.suggestFontSize === other.suggestFontSize
&& this.suggestLineHeight === other.suggestLineHeight
&& this.selectionHighlight === other.selectionHighlight
&& this.codeLens === other.codeLens
&& this.folding === other.folding
......
......@@ -82,22 +82,26 @@ class Renderer implements IRenderer<ICompletionItem, ISuggestionTemplateData> {
data.documentationDetails.title = nls.localize('readMore', "Read More...{0}", this.triggerKeybindingLabel);
const configureFont = () => {
const fontInfo = this.editor.getConfiguration().fontInfo;
const lineHeight = `${ fontInfo.lineHeight }px`;
data.root.style.fontSize = `${ fontInfo.fontSize }px`;
main.style.fontFamily = fontInfo.fontFamily;
main.style.lineHeight = lineHeight;
data.icon.style.height = lineHeight;
data.icon.style.width = lineHeight;
data.documentationDetails.style.height = lineHeight;
data.documentationDetails.style.width = lineHeight;
const configuration = this.editor.getConfiguration();
const fontFamily = configuration.fontInfo.fontFamily;
const fontSize = configuration.contribInfo.suggestFontSize || configuration.fontInfo.fontSize;
const lineHeight = configuration.contribInfo.suggestLineHeight || configuration.fontInfo.lineHeight;
const fontSizePx = `${ fontSize }px`;
const lineHeightPx = `${ lineHeight }px`;
data.root.style.fontSize = fontSizePx;
main.style.fontFamily = fontFamily;
main.style.lineHeight = lineHeightPx;
data.icon.style.height = lineHeightPx;
data.icon.style.width = lineHeightPx;
data.documentationDetails.style.height = lineHeightPx;
data.documentationDetails.style.width = lineHeightPx;
};
configureFont();
chain<IConfigurationChangedEvent>(this.editor.onDidChangeConfiguration.bind(this.editor))
.filter(e => e.fontInfo)
.filter(e => e.fontInfo || e.contribInfo)
.on(configureFont, null, data.disposables);
return data;
......@@ -262,15 +266,18 @@ class SuggestionDetails {
}
private configureFont() {
const fontInfo = this.editor.getConfiguration().fontInfo;
const fontSize = `${ fontInfo.fontSize }px`;
const lineHeight = `${ fontInfo.lineHeight }px`;
const configuration = this.editor.getConfiguration();
const fontFamily = configuration.fontInfo.fontFamily;
const fontSize = configuration.contribInfo.suggestFontSize || configuration.fontInfo.fontSize;
const lineHeight = configuration.contribInfo.suggestLineHeight || configuration.fontInfo.lineHeight;
const fontSizePx = `${ fontSize }px`;
const lineHeightPx = `${ lineHeight }px`;
this.el.style.fontSize = fontSize;
this.title.style.fontFamily = fontInfo.fontFamily;
this.type.style.fontFamily = fontInfo.fontFamily;
this.back.style.height = lineHeight;
this.back.style.width = lineHeight;
this.el.style.fontSize = fontSizePx;
this.title.style.fontFamily = fontFamily;
this.type.style.fontFamily = fontFamily;
this.back.style.height = lineHeightPx;
this.back.style.width = lineHeightPx;
}
dispose(): void {
......@@ -754,8 +761,8 @@ export class SuggestWidget implements IContentWidget, IDelegate<ICompletionItem>
}
private get unfocusedHeight(): number {
const fontInfo = this.editor.getConfiguration().fontInfo;
return fontInfo.lineHeight;
const configuration = this.editor.getConfiguration();
return configuration.contribInfo.suggestLineHeight || configuration.fontInfo.lineHeight;
}
// IDelegate
......
......@@ -1273,6 +1273,16 @@ declare module monaco.editor {
* Enable word based suggestions. Defaults to 'true'
*/
wordBasedSuggestions?: boolean;
/**
* The font size for the suggest widget.
* Defaults to the editor font size.
*/
suggestFontSize?: number;
/**
* The line height for the suggest widget.
* Defaults to the editor line height.
*/
suggestLineHeight?: number;
/**
* Enable selection highlight.
* Defaults to true.
......@@ -1453,6 +1463,8 @@ declare module monaco.editor {
snippetSuggestions: 'top' | 'bottom' | 'inline' | 'none';
tabCompletion: boolean;
wordBasedSuggestions: boolean;
suggestFontSize: number;
suggestLineHeight: number;
selectionHighlight: boolean;
codeLens: boolean;
folding: boolean;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册