From f6fabebf8db28e4a8139e5c357564ec61c1f2dcb Mon Sep 17 00:00:00 2001 From: Jason Lin Date: Fri, 21 Oct 2022 11:48:07 +1100 Subject: [PATCH] polish --- src/common/InputHandler.test.ts | 11 ++++------- src/common/InputHandler.ts | 12 ++++++------ 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/common/InputHandler.test.ts b/src/common/InputHandler.test.ts index 38c7acf3..110e4f51 100644 --- a/src/common/InputHandler.test.ts +++ b/src/common/InputHandler.test.ts @@ -9,7 +9,7 @@ import { IBufferLine, IAttributeData, IColorEvent, ColorIndex, ColorRequestType import { DEFAULT_ATTR_DATA } from 'common/buffer/BufferLine'; import { CellData } from 'common/buffer/CellData'; import { Attributes, BgFlags, UnderlineStyle } from 'common/buffer/Constants'; -import { AttributeData } from 'common/buffer/AttributeData'; +import { AttributeData, ExtendedAttrs } from 'common/buffer/AttributeData'; import { Params } from 'common/parser/Params'; import { MockCoreService, MockBufferService, MockOptionsService, MockLogService, MockCoreMouseService, MockCharsetService, MockUnicodeService, MockOscLinkService } from 'common/TestUtils.test'; import { IBufferService, ICoreService } from 'common/services/Services'; @@ -1714,12 +1714,9 @@ describe('InputHandler', () => { await inputHandler.parseP('\x1b[m'); assert.equal(inputHandler.curAttrData.fg, 0); assert.equal(inputHandler.curAttrData.bg, BgFlags.HAS_EXTENDED); - assert.equal(inputHandler.curAttrData.extended.urlId, urlId); - // Check that `extended._ext === 0`. Note that `extended.ext` does not - // equal `extended._ext` because it is affected by the url. - const extended = inputHandler.curAttrData.extended.clone(); - extended.urlId = 0; - assert.equal(extended.ext, 0); + const expectedExtended = new ExtendedAttrs(); + expectedExtended.urlId = urlId; + assert.deepEqual(inputHandler.curAttrData.extended, expectedExtended); }); }); diff --git a/src/common/InputHandler.ts b/src/common/InputHandler.ts index 8674e80a..ac3c676d 100644 --- a/src/common/InputHandler.ts +++ b/src/common/InputHandler.ts @@ -2360,14 +2360,14 @@ export class InputHandler extends Disposable implements IInputHandler { attr.fg = DEFAULT_ATTR_DATA.fg; attr.bg = DEFAULT_ATTR_DATA.bg; + // Reset `extended` except for the `urlId`. if (!attr.extended.isEmpty()) { - // Treat extended attrs as immutable, thus always clone from old one. - // This is needed since the buffer only holds references to it. - attr.extended = attr.extended.clone(); - attr.extended.ext = 0; + const urlId = attr.extended.urlId; + attr.extended = DEFAULT_ATTR_DATA.extended.clone(); - if (attr.extended.urlId) { - attr.bg |= BgFlags.HAS_EXTENDED; + if (urlId) { + attr.extended.urlId = urlId; + attr.updateExtended(); } } }