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

support custom cursor height #28109

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 5 additions & 2 deletions src/vs/editor/browser/viewParts/viewCursors/viewCursor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ export class ViewCursor {
private readonly _domNode: FastDomNode<HTMLElement>;

private _cursorStyle: TextEditorCursorStyle;

private _cursorHeightMultiplier: number;
private _lineHeight: number;
private _typicalHalfwidthCharacterWidth: number;

Expand All @@ -59,6 +61,7 @@ export class ViewCursor {
this._cursorStyle = this._context.configuration.editor.viewInfo.cursorStyle;
this._lineHeight = this._context.configuration.editor.lineHeight;
this._typicalHalfwidthCharacterWidth = this._context.configuration.editor.fontInfo.typicalHalfwidthCharacterWidth;
this._cursorHeightMultiplier = this._context.configuration.editor.cursorHeightMultiplier || 1;

this._isVisible = true;

Expand All @@ -69,7 +72,7 @@ export class ViewCursor {
} else {
this._domNode.setClassName('cursor');
}
this._domNode.setHeight(this._lineHeight);
this._domNode.setHeight(this._lineHeight * this._cursorHeightMultiplier);
this._domNode.setTop(0);
this._domNode.setLeft(0);
Configuration.applyFontInfo(this._domNode, this._context.configuration.editor.fontInfo);
Expand Down Expand Up @@ -185,7 +188,7 @@ export class ViewCursor {
this._domNode.setLeft(this._renderData.left);
this._domNode.setWidth(this._renderData.width);
this._domNode.setLineHeight(this._lineHeight);
this._domNode.setHeight(this._lineHeight);
this._domNode.setHeight(this._lineHeight * this._cursorHeightMultiplier);

return {
domNode: this._domNode.domNode,
Expand Down
5 changes: 5 additions & 0 deletions src/vs/editor/common/config/commonEditorConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,11 @@ const editorConfiguration: IConfigurationNode = {
'default': EDITOR_FONT_DEFAULTS.lineHeight,
'description': nls.localize('lineHeight', "Controls the line height. Use 0 to compute the lineHeight from the fontSize.")
},
'editor.cursorHeightMultiplier': {
'type': 'number',
'default': EDITOR_FONT_DEFAULTS.cursorHeightMultiplier,
'description': nls.localize('cursorHeightMultiplier', "Controls how tall the cursor is. This will be multiplied with editor.lineHeight.")
},
'editor.letterSpacing': {
'type': 'number',
'default': EDITOR_FONT_DEFAULTS.letterSpacing,
Expand Down
2 changes: 2 additions & 0 deletions src/vs/editor/common/config/editorOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -810,6 +810,7 @@ export class InternalEditorOptions {
readonly pixelRatio: number;
readonly editorClassName: string;
readonly lineHeight: number;
readonly cursorHeightMultiplier: number;
readonly readOnly: boolean;
/**
* @internal
Expand Down Expand Up @@ -2039,6 +2040,7 @@ export const EDITOR_FONT_DEFAULTS = {
),
lineHeight: 0,
letterSpacing: 0,
cursorHeightMultiplier: 1
};

/**
Expand Down