Tidy up syncTextArea

This commit is contained in:
Daniel Imms
2021-04-01 12:05:24 -07:00
parent 07499380d1
commit 87ed4f07cd
+6 -5
View File
@@ -301,21 +301,22 @@ export class Terminal extends CoreTerminal implements ITerminal {
return; return;
} }
const cursorY = this.buffer.ybase + this.buffer.y; const cursorY = this.buffer.ybase + this.buffer.y;
const viewportRelativeCursorY = cursorY - this.buffer.ydisp; const bufferLine = this.buffer.lines.get(cursorY);
if (!bufferLine) {
return;
}
const cursorX = Math.min(this.buffer.x, this.cols - 1); const cursorX = Math.min(this.buffer.x, this.cols - 1);
const cellHeight = this._renderService.dimensions.actualCellHeight; const cellHeight = this._renderService.dimensions.actualCellHeight;
const bufferLine = this.buffer.lines.get(cursorY);
if (!bufferLine) return;
const width = bufferLine.getWidth(cursorX); const width = bufferLine.getWidth(cursorX);
const cellWidth = this._renderService.dimensions.actualCellWidth * width; const cellWidth = this._renderService.dimensions.actualCellWidth * width;
const cursorTop = viewportRelativeCursorY * this._renderService.dimensions.actualCellHeight; const cursorTop = this.buffer.y * this._renderService.dimensions.actualCellHeight;
const cursorLeft = cursorX * this._renderService.dimensions.actualCellWidth; const cursorLeft = cursorX * this._renderService.dimensions.actualCellWidth;
// Sync the textarea to the exact position of the composition view so the IME knows where the // Sync the textarea to the exact position of the composition view so the IME knows where the
// text is. // text is.
this.textarea.style.left = cursorLeft + 'px'; this.textarea.style.left = cursorLeft + 'px';
this.textarea.style.top = cursorTop + 'px'; this.textarea.style.top = cursorTop + 'px';
this.textarea.style.width = cellWidth +'px'; this.textarea.style.width = cellWidth + 'px';
this.textarea.style.height = cellHeight + 'px'; this.textarea.style.height = cellHeight + 'px';
this.textarea.style.lineHeight = cellHeight + 'px'; this.textarea.style.lineHeight = cellHeight + 'px';
this.textarea.style.zIndex = '-5'; this.textarea.style.zIndex = '-5';