@@ -2,10 +2,16 @@ import { Color, namedColors } from './colors';
22import { DecorationType , decorations } from './decorations' ;
33
44export interface ParseToken {
5+ /** The text content of the token. */
56 value : string ;
7+ /** The foreground color */
68 foreground : Color | null ;
9+ /** The background color. */
710 background : Color | null ;
11+ /** A Set of the applied decorations. */
812 decorations : Set < DecorationType > ;
13+ /** Offset from the beginning of the input value. */
14+ offset : number ;
915}
1016
1117function findSequence ( value : string , position : number ) {
@@ -153,6 +159,7 @@ export function createAnsiSequenceParser() {
153159 let foreground : Color | null = null ;
154160 let background : Color | null = null ;
155161 let decorations : Set < DecorationType > = new Set ( ) ;
162+ let chunkOffset = 0 ;
156163
157164 return {
158165 parse ( value : string ) {
@@ -172,6 +179,7 @@ export function createAnsiSequenceParser() {
172179 foreground,
173180 background,
174181 decorations : new Set ( decorations ) ,
182+ offset : chunkOffset + position
175183 } ) ;
176184 }
177185
@@ -208,6 +216,8 @@ export function createAnsiSequenceParser() {
208216 position = findResult . position ;
209217 } while ( position < value . length ) ;
210218
219+ chunkOffset += value . length ;
220+
211221 return tokens ;
212222 } ,
213223 } ;
0 commit comments