This commit is contained in:
Jason Lin
2022-10-31 11:07:42 +11:00
committed by Jason Lin
parent b735e7f1c4
commit f6fabebf8d
2 changed files with 10 additions and 13 deletions
+4 -7
View File
@@ -9,7 +9,7 @@ import { IBufferLine, IAttributeData, IColorEvent, ColorIndex, ColorRequestType
import { DEFAULT_ATTR_DATA } from 'common/buffer/BufferLine'; import { DEFAULT_ATTR_DATA } from 'common/buffer/BufferLine';
import { CellData } from 'common/buffer/CellData'; import { CellData } from 'common/buffer/CellData';
import { Attributes, BgFlags, UnderlineStyle } from 'common/buffer/Constants'; 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 { Params } from 'common/parser/Params';
import { MockCoreService, MockBufferService, MockOptionsService, MockLogService, MockCoreMouseService, MockCharsetService, MockUnicodeService, MockOscLinkService } from 'common/TestUtils.test'; import { MockCoreService, MockBufferService, MockOptionsService, MockLogService, MockCoreMouseService, MockCharsetService, MockUnicodeService, MockOscLinkService } from 'common/TestUtils.test';
import { IBufferService, ICoreService } from 'common/services/Services'; import { IBufferService, ICoreService } from 'common/services/Services';
@@ -1714,12 +1714,9 @@ describe('InputHandler', () => {
await inputHandler.parseP('\x1b[m'); await inputHandler.parseP('\x1b[m');
assert.equal(inputHandler.curAttrData.fg, 0); assert.equal(inputHandler.curAttrData.fg, 0);
assert.equal(inputHandler.curAttrData.bg, BgFlags.HAS_EXTENDED); assert.equal(inputHandler.curAttrData.bg, BgFlags.HAS_EXTENDED);
assert.equal(inputHandler.curAttrData.extended.urlId, urlId); const expectedExtended = new ExtendedAttrs();
// Check that `extended._ext === 0`. Note that `extended.ext` does not expectedExtended.urlId = urlId;
// equal `extended._ext` because it is affected by the url. assert.deepEqual(inputHandler.curAttrData.extended, expectedExtended);
const extended = inputHandler.curAttrData.extended.clone();
extended.urlId = 0;
assert.equal(extended.ext, 0);
}); });
}); });
+6 -6
View File
@@ -2360,14 +2360,14 @@ export class InputHandler extends Disposable implements IInputHandler {
attr.fg = DEFAULT_ATTR_DATA.fg; attr.fg = DEFAULT_ATTR_DATA.fg;
attr.bg = DEFAULT_ATTR_DATA.bg; attr.bg = DEFAULT_ATTR_DATA.bg;
// Reset `extended` except for the `urlId`.
if (!attr.extended.isEmpty()) { if (!attr.extended.isEmpty()) {
// Treat extended attrs as immutable, thus always clone from old one. const urlId = attr.extended.urlId;
// This is needed since the buffer only holds references to it. attr.extended = DEFAULT_ATTR_DATA.extended.clone();
attr.extended = attr.extended.clone();
attr.extended.ext = 0;
if (attr.extended.urlId) { if (urlId) {
attr.bg |= BgFlags.HAS_EXTENDED; attr.extended.urlId = urlId;
attr.updateExtended();
} }
} }
} }