提交 4f9f06cd 编写于 作者: J Joao Moreno

use editor font in rename widget

上级 ca20cad6
......@@ -15,7 +15,6 @@
.monaco-editor .rename-box .rename-input {
border: 1px solid #39F;
font-size: 13px;
padding: 4px;
}
......
......@@ -21,6 +21,7 @@ export default class RenameInputField implements IContentWidget, IDisposable {
private _domNode: HTMLElement;
private _inputField: HTMLInputElement;
private _visible: boolean;
private _disposables: IDisposable[] = [];
// Editor.IContentWidget.allowEditorOverflow
public allowEditorOverflow: boolean = true;
......@@ -28,9 +29,16 @@ export default class RenameInputField implements IContentWidget, IDisposable {
constructor(editor: ICodeEditor) {
this._editor = editor;
this._editor.addContentWidget(this);
this._disposables.push(editor.onDidChangeConfiguration(e => {
if (e.fontInfo) {
this.updateFont();
}
}));
}
public dispose(): void {
this._disposables = dispose(this._disposables);
this._editor.removeContentWidget(this);
}
......@@ -48,10 +56,22 @@ export default class RenameInputField implements IContentWidget, IDisposable {
this._domNode.style.height = `${this._editor.getConfiguration().lineHeight}px`;
this._domNode.className = 'monaco-editor rename-box';
this._domNode.appendChild(this._inputField);
this.updateFont();
}
return this._domNode;
}
private updateFont(): void {
if (!this._inputField) {
return;
}
const fontInfo = this._editor.getConfiguration().fontInfo;
this._inputField.style.fontFamily = fontInfo.fontFamily;
this._inputField.style.fontSize = `${ fontInfo.fontSize }px`;
}
public getPosition(): IContentWidgetPosition {
return this._visible
? { position: this._position, preference: [ContentWidgetPositionPreference.BELOW, ContentWidgetPositionPreference.ABOVE] }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册