From 2032f409cfd7bf9091d8b0fc5b7baf80383e83cd Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Fri, 9 Sep 2022 12:28:27 -0700 Subject: [PATCH 1/2] Copy extended attributes to dest in reflow Fixes #4108 --- src/common/buffer/BufferLine.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/common/buffer/BufferLine.ts b/src/common/buffer/BufferLine.ts index eed87e6b..d8cb4355 100644 --- a/src/common/buffer/BufferLine.ts +++ b/src/common/buffer/BufferLine.ts @@ -5,7 +5,7 @@ import { CharData, IBufferLine, ICellData, IAttributeData, IExtendedAttrs } from 'common/Types'; import { stringFromCodePoint } from 'common/input/TextDecoder'; -import { CHAR_DATA_CHAR_INDEX, CHAR_DATA_WIDTH_INDEX, CHAR_DATA_ATTR_INDEX, NULL_CELL_CHAR, NULL_CELL_WIDTH, NULL_CELL_CODE, WHITESPACE_CELL_CHAR, Content, BgFlags } from 'common/buffer/Constants'; +import { CHAR_DATA_CHAR_INDEX, CHAR_DATA_WIDTH_INDEX, CHAR_DATA_ATTR_INDEX, NULL_CELL_CHAR, NULL_CELL_WIDTH, NULL_CELL_CODE, WHITESPACE_CELL_CHAR, Content, BgFlags, FgFlags } from 'common/buffer/Constants'; import { CellData } from 'common/buffer/CellData'; import { AttributeData, ExtendedAttrs } from 'common/buffer/AttributeData'; @@ -411,12 +411,18 @@ export class BufferLine implements IBufferLine { for (let i = 0; i < CELL_SIZE; i++) { this._data[(destCol + cell) * CELL_SIZE + i] = srcData[(srcCol + cell) * CELL_SIZE + i]; } + if (srcData[(srcCol + cell) * CELL_SIZE + Cell.BG] & BgFlags.HAS_EXTENDED) { + this._extendedAttrs[destCol + cell] = src._extendedAttrs[srcCol + cell]; + } } } else { for (let cell = 0; cell < length; cell++) { for (let i = 0; i < CELL_SIZE; i++) { this._data[(destCol + cell) * CELL_SIZE + i] = srcData[(srcCol + cell) * CELL_SIZE + i]; } + if (srcData[(srcCol + cell) * CELL_SIZE + Cell.BG] & BgFlags.HAS_EXTENDED) { + this._extendedAttrs[destCol + cell] = src._extendedAttrs[srcCol + cell]; + } } } From 822ac527ba1f6a0930df81254daaab405a0098f0 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Fri, 9 Sep 2022 12:48:55 -0700 Subject: [PATCH 2/2] Correct type and use ! to highlight the unsafe part --- src/common/buffer/BufferLine.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/buffer/BufferLine.ts b/src/common/buffer/BufferLine.ts index d8cb4355..a1c7f257 100644 --- a/src/common/buffer/BufferLine.ts +++ b/src/common/buffer/BufferLine.ts @@ -60,7 +60,7 @@ const w: { startIndex: number } = { export class BufferLine implements IBufferLine { protected _data: Uint32Array; protected _combined: {[index: number]: string} = {}; - protected _extendedAttrs: {[index: number]: IExtendedAttrs} = {}; + protected _extendedAttrs: {[index: number]: IExtendedAttrs | undefined} = {}; public length: number; constructor(cols: number, fillCellData?: ICellData, public isWrapped: boolean = false) { @@ -181,7 +181,7 @@ export class BufferLine implements IBufferLine { cell.combinedData = this._combined[index]; } if (cell.bg & BgFlags.HAS_EXTENDED) { - cell.extended = this._extendedAttrs[index]; + cell.extended = this._extendedAttrs[index]!; } return cell; }