Colocate circular list types in CircularList.ts

The import/no-cycle refactor had moved IInsertEvent, IDeleteEvent, and
ICircularList into Types.ts, with CircularList.ts re-exporting the event
types from there. That split the list abstraction from its implementation
and pulled Types into the circular-list dependency graph.

Define IInsertEvent, IDeleteEvent, and ICircularList in CircularList.ts
alongside the CircularList class. CircularList.ts now depends only on
Lifecycle and Event, not Types.ts.

Remove those definitions from Types.ts (and the unused Emitter import).

Update callers to import list types from CircularList:
- buffer/Types.ts (IBuffer.lines)
- DecorationService.ts (buffer line insert/delete handlers)
- browser TestUtils.test.ts (mock buffer lines)

Types.ts no longer imports or re-exports circular-list types, preserving
the acyclic Types -> buffer/CircularList boundary.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Daniel Imms
2026-05-31 14:37:01 -07:00
co-authored by Cursor
parent cd3dcc52b2
commit 5684f95c8e
5 changed files with 39 additions and 40 deletions
+2 -1
View File
@@ -8,7 +8,8 @@ import { ICharacterJoinerService, ICharSizeService, ICoreBrowserService, IMouseS
import { IRenderDimensions, IRenderer, IRequestRedrawEvent } from './renderer/shared/Types';
import { IColorSet, ITerminal, ILinkifier2, IBrowser, IViewport, ICompositionHelper, CharacterJoinerHandler, IBufferRange, ReadonlyColorSet, IBufferElementProvider } from './Types';
import { IAttributeData, IBuffer, IBufferLine, IBufferSet, ICellData } from '../common/buffer/Types';
import { ICircularList, XtermListener, ICharset, ITerminalOptions, ColorIndex } from '../common/Types';
import { ICircularList } from '../common/CircularList';
import { XtermListener, ICharset, ITerminalOptions, ColorIndex } from '../common/Types';
import { Buffer } from '../common/buffer/Buffer';
import * as Browser from '../common/Platform';
import { CoreBrowserTerminal } from './CoreBrowserTerminal';
+32 -3
View File
@@ -3,11 +3,40 @@
* @license MIT
*/
import { ICircularList, IDeleteEvent, IInsertEvent } from './Types';
import { Disposable } from './Lifecycle';
import { Emitter } from './Event';
import { Emitter, type IEvent } from './Event';
export type { IDeleteEvent, IInsertEvent } from './Types';
export interface IInsertEvent {
index: number;
amount: number;
}
export interface IDeleteEvent {
index: number;
amount: number;
}
export interface ICircularList<T> {
length: number;
maxLength: number;
isFull: boolean;
onDeleteEmitter: Emitter<IDeleteEvent>;
onDelete: IEvent<IDeleteEvent>;
onInsertEmitter: Emitter<IInsertEvent>;
onInsert: IEvent<IInsertEvent>;
onTrimEmitter: Emitter<number>;
onTrim: IEvent<number>;
get(index: number): T | undefined;
set(index: number, value: T): void;
push(value: T): void;
recycle(): T;
pop(): T | undefined;
splice(start: number, deleteCount: number, ...items: T[]): void;
trimStart(count: number): void;
shiftElements(start: number, count: number, offset: number): void;
}
/**
* Represents a circular list; a list with a maximum size that wraps around when push is called,
+1 -33
View File
@@ -4,17 +4,7 @@
*/
import { IFunctionIdentifier, ITerminalOptions as IPublicTerminalOptions } from '@xterm/xterm';
import type { Emitter, IEvent } from './Event';
export interface IInsertEvent {
index: number;
amount: number;
}
export interface IDeleteEvent {
index: number;
amount: number;
}
import type { IEvent } from './Event';
/** sequence params serialized to js arrays */
export type ParamsArray = (number | number[])[];
@@ -78,28 +68,6 @@ export interface IScrollEvent {
position: number;
}
export interface ICircularList<T> {
length: number;
maxLength: number;
isFull: boolean;
onDeleteEmitter: Emitter<IDeleteEvent>;
onDelete: IEvent<IDeleteEvent>;
onInsertEmitter: Emitter<IInsertEvent>;
onInsert: IEvent<IInsertEvent>;
onTrimEmitter: Emitter<number>;
onTrim: IEvent<number>;
get(index: number): T | undefined;
set(index: number, value: T): void;
push(value: T): void;
recycle(): T;
pop(): T | undefined;
splice(start: number, deleteCount: number, ...items: T[]): void;
trimStart(count: number): void;
shiftElements(start: number, count: number, offset: number): void;
}
export const enum KeyboardResultType {
SEND_KEY,
SELECT_ALL,
+2 -1
View File
@@ -4,7 +4,8 @@
*/
import type { IEvent } from '../Event';
import type { ICircularList, ICharset } from '../Types';
import type { ICircularList } from '../CircularList';
import type { ICharset } from '../Types';
import type { IDisposable } from '../Lifecycle';
import type { UnderlineStyle } from './Constants';
+2 -2
View File
@@ -3,13 +3,13 @@
* @license MIT
*/
import type { IDeleteEvent, IInsertEvent } from '../CircularList';
import type { ICircularList, IDeleteEvent, IInsertEvent } from '../CircularList';
import { MicrotaskTimer } from '../Async';
import { css } from '../Color';
import { Disposable, DisposableStore, MutableDisposable, toDisposable } from '../Lifecycle';
import { IBufferService, IDecorationService, IInternalDecoration, ILogService } from './Services';
import { SortedList } from '../SortedList';
import { IColor, ICircularList } from '../Types';
import { IColor } from '../Types';
import { IDecoration, IDecorationOptions, IMarker } from '@xterm/xterm';
import { Emitter } from '../Event';