mirror of
https://github.com/Microsoft/vscode
synced 2024-10-30 21:06:57 +00:00
Change terminal dimensions based on renderer type
The canvas and webgl renderers use a flat integer for width whereas dom uses a floating point number. This was causing canvas/webgl to be more narrow than they should be. Since changing rendererType is a pretty infrequent thing it should be fine to resize for this. Fixes #86425
This commit is contained in:
parent
ddebb29935
commit
5b0460a67e
2 changed files with 23 additions and 5 deletions
|
@ -124,9 +124,23 @@ export class TerminalConfigHelper implements IBrowserTerminalConfigHelper {
|
|||
fontSize,
|
||||
letterSpacing,
|
||||
lineHeight,
|
||||
charWidth: rect && rect.width ? rect.width : 0,
|
||||
charHeight: rect && rect.height ? Math.ceil(rect.height) : 0
|
||||
charWidth: 0,
|
||||
charHeight: 0
|
||||
};
|
||||
|
||||
if (rect && rect.width && rect.height) {
|
||||
this._lastFontMeasurement.charHeight = Math.ceil(rect.height);
|
||||
// Char width is calculated differently for DOM and the other renderer types. Refer to
|
||||
// how each renderer updates their dimensions in xterm.js
|
||||
if (this.config.rendererType === 'dom') {
|
||||
this._lastFontMeasurement.charWidth = rect.width;
|
||||
} else {
|
||||
const scaledCharWidth = rect.width * window.devicePixelRatio;
|
||||
const scaledCellWidth = scaledCharWidth + Math.round(letterSpacing);
|
||||
this._lastFontMeasurement.charWidth = Math.round(scaledCellWidth / window.devicePixelRatio);
|
||||
}
|
||||
}
|
||||
|
||||
return this._lastFontMeasurement;
|
||||
}
|
||||
|
||||
|
@ -167,14 +181,14 @@ export class TerminalConfigHelper implements IBrowserTerminalConfigHelper {
|
|||
|
||||
// Get the character dimensions from xterm if it's available
|
||||
if (xtermCore) {
|
||||
if (xtermCore._charSizeService && xtermCore._charSizeService.width && xtermCore._charSizeService.height) {
|
||||
if (xtermCore._renderService && xtermCore._renderService.dimensions?.actualCellWidth && xtermCore._renderService.dimensions?.actualCellHeight) {
|
||||
return {
|
||||
fontFamily,
|
||||
fontSize,
|
||||
letterSpacing,
|
||||
lineHeight,
|
||||
charHeight: xtermCore._charSizeService.height,
|
||||
charWidth: xtermCore._charSizeService.width
|
||||
charHeight: xtermCore._renderService.dimensions.actualCellHeight,
|
||||
charWidth: xtermCore._renderService.dimensions.actualCellWidth
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,6 +17,10 @@ export interface XTermCore {
|
|||
};
|
||||
|
||||
_renderService: {
|
||||
dimensions: {
|
||||
actualCellWidth: number;
|
||||
actualCellHeight: number;
|
||||
},
|
||||
_renderer: {
|
||||
_renderLayers: any[];
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue