Merge pull request #5780 from PerBothner/extendedAttrs-test

Move extendedAttributes function to TestUtils
This commit is contained in:
Daniel Imms
2026-03-26 07:58:38 -07:00
committed by GitHub
3 changed files with 15 additions and 15 deletions
+6 -6
View File
@@ -11,7 +11,7 @@ import { CellData } from 'common/buffer/CellData';
import { Attributes, BgFlags, UnderlineStyle } from 'common/buffer/Constants';
import { AttributeData, ExtendedAttrs } from 'common/buffer/AttributeData';
import { Params } from 'common/parser/Params';
import { MockCoreService, MockBufferService, MockOptionsService, MockLogService, MockMouseStateService, MockCharsetService, MockUnicodeService, MockOscLinkService } from 'common/TestUtils.test';
import { MockCoreService, MockBufferService, MockOptionsService, MockLogService, MockMouseStateService, MockCharsetService, MockUnicodeService, MockOscLinkService, extendedAttributes } from 'common/TestUtils.test';
import { IBufferService, ICoreService, type IOscLinkService } from 'common/services/Services';
import { DEFAULT_OPTIONS } from 'common/services/OptionsService';
import { clone } from 'common/Clone';
@@ -2002,15 +2002,15 @@ describe('InputHandler', () => {
// eAttrs in buffer pos 0 and 1 should be the same object
assert.equal(
(bufferService.buffer!.lines.get(0)! as any)._extendedAttrs[0],
(bufferService.buffer!.lines.get(0)! as any)._extendedAttrs[1]
extendedAttributes(bufferService.buffer!.lines.get(0)!, 0),
extendedAttributes(bufferService.buffer!.lines.get(0)!, 1)
);
// should not have written eAttr for pos 2 in the buffer
assert.equal((bufferService.buffer!.lines.get(0)! as any)._extendedAttrs[2], undefined);
assert.equal(extendedAttributes(bufferService.buffer!.lines.get(0)!, 2), undefined);
// eAttrs in buffer pos 1 and pos 3 must be different objs
assert.notEqual(
(bufferService.buffer!.lines.get(0)! as any)._extendedAttrs[1],
(bufferService.buffer!.lines.get(0)! as any)._extendedAttrs[3]
extendedAttributes(bufferService.buffer!.lines.get(0)!, 1),
extendedAttributes(bufferService.buffer!.lines.get(0)!, 3)
);
});
});
+7 -1
View File
@@ -9,7 +9,7 @@ import { clone } from 'common/Clone';
import { DEFAULT_OPTIONS } from 'common/services/OptionsService';
import { IBufferSet, IBuffer } from 'common/buffer/Types';
import { BufferSet } from 'common/buffer/BufferSet';
import { IDecPrivateModes, ICoreMouseEvent, CoreMouseEventType, ICharset, IModes, IAttributeData, IOscLinkData, IDisposable } from 'common/Types';
import { IDecPrivateModes, ICoreMouseEvent, CoreMouseEventType, ICharset, IModes, IAttributeData, IOscLinkData, IDisposable, IBufferLine, IExtendedAttrs } from 'common/Types';
import { UnicodeV6 } from 'common/input/UnicodeV6';
import { IDecorationOptions, IDecoration } from '@xterm/xterm';
import { Emitter, type IEvent } from 'common/Event';
@@ -20,6 +20,12 @@ export function createCellData(attr: number, char: string, width: number): CellD
return CellData.fromCharData([attr, char, width, char.length === 0 ? 0 : char.charCodeAt(0)]);
}
export function extendedAttributes(line: IBufferLine, index: number): IExtendedAttrs | undefined {
const cell = new CellData();
line.loadCell(index, cell);
return cell.hasExtendedAttrs() !== 0 ? cell.extended : undefined;
}
export const NULL_CELL_DATA = Object.freeze(createCellData(DEFAULT_ATTR, NULL_CELL_CHAR, NULL_CELL_WIDTH));
export class MockBufferService implements IBufferService {
+2 -8
View File
@@ -5,10 +5,10 @@
import { NULL_CELL_CHAR, NULL_CELL_WIDTH, NULL_CELL_CODE, DEFAULT_ATTR, Content, UnderlineStyle, BgFlags, Attributes, FgFlags } from 'common/buffer/Constants';
import { BufferLine } from 'common/buffer//BufferLine';
import { CellData } from 'common/buffer/CellData';
import { CharData, IBufferLine, IExtendedAttrs } from '../Types';
import { CharData, IBufferLine } from '../Types';
import { assert } from 'chai';
import { AttributeData } from 'common/buffer/AttributeData';
import { createCellData, NULL_CELL_DATA } from 'common/TestUtils.test';
import { createCellData, NULL_CELL_DATA, extendedAttributes } from 'common/TestUtils.test';
class TestBufferLine extends BufferLine {
@@ -25,12 +25,6 @@ class TestBufferLine extends BufferLine {
}
}
function extendedAttributes(line: IBufferLine, index: number): IExtendedAttrs | undefined {
const cell = new CellData();
line.loadCell(index, cell);
return cell.hasExtendedAttrs() !== 0 ? cell.extended : undefined;
}
describe('AttributeData', () => {
describe('extended attributes', () => {
it('hasExtendedAttrs', () => {