55
66import { mkdir , rename } from 'fs/promises' ;
77import { env } from 'vscode' ;
8- import { LogDocumentId , LogEntry , serializeEdit , serializeOffsetRange } from '../../../platform/workspaceRecorder/common/workspaceLog' ;
8+ import { IChangedMetadata , LogDocumentId , LogEntry , serializeEdit , serializeOffsetRange } from '../../../platform/workspaceRecorder/common/workspaceLog' ;
99import { TaskQueue } from '../../../util/common/async' ;
1010import { timeout } from '../../../util/vs/base/common/async' ;
1111import { BugIndicatingError } from '../../../util/vs/base/common/errors' ;
@@ -51,10 +51,10 @@ export class WorkspaceRecorder extends Disposable {
5151 this . _schedule ( ( ) => this . _impl . then ( v => v . handleOnDidHideTextDocument ( this . _getTime ( ) , documentUri ) ) ) ;
5252 }
5353
54- handleOnDidChangeTextDocument ( documentUri : string , edit : StringEdit , newModelVersion : number ) : void {
54+ handleOnDidChangeTextDocument ( documentUri : string , edit : StringEdit , newModelVersion : number , metadata : IChangedMetadata | undefined ) : void {
5555 if ( edit . isEmpty ( ) ) { return ; }
5656
57- this . _schedule ( ( ) => this . _impl . then ( v => v . handleOnDidChangeTextDocument ( this . _getTime ( ) , documentUri , edit , newModelVersion ) ) ) ;
57+ this . _schedule ( ( ) => this . _impl . then ( v => v . handleOnDidChangeTextDocument ( this . _getTime ( ) , documentUri , edit , newModelVersion , metadata ) ) ) ;
5858 }
5959
6060 handleOnDidFocusedDocumentChange ( documentUri : string ) : void {
@@ -90,7 +90,7 @@ export class WorkspaceRecorderImpl extends Disposable {
9090 public static async create ( repoRootUri : string , recordingDirPath : string , logFilePath : string , context : IWorkspaceRecorderContext ) : Promise < WorkspaceRecorderImpl > {
9191 await mkdir ( recordingDirPath , { recursive : true } ) ;
9292
93- const currentVersion = 3 ;
93+ const currentVersion = 4 ;
9494
9595 const state = await FlushableJSONFile . loadOrCreate < WorkspaceRecordingState > ( path . join ( recordingDirPath , 'state.json' ) , {
9696 version : currentVersion ,
@@ -143,7 +143,7 @@ export class WorkspaceRecorderImpl extends Disposable {
143143 }
144144
145145 const log = new FlushableSafeJSONLFile < LogEntry > ( logFilePath ) ;
146- return new WorkspaceRecorderImpl ( repoRootUri , state , log , context , logFileExists ) ;
146+ return new WorkspaceRecorderImpl ( repoRootUri , state , log , context , logFileExists , currentVersion ) ;
147147 }
148148
149149 private constructor (
@@ -152,6 +152,7 @@ export class WorkspaceRecorderImpl extends Disposable {
152152 private readonly _log : FlushableSafeJSONLFile < LogEntry > ,
153153 private readonly _context : IWorkspaceRecorderContext ,
154154 private readonly _logFileExists : boolean ,
155+ private readonly _revision : number ,
155156 ) {
156157 super ( ) ;
157158 this . _register ( toDisposable ( ( ) => {
@@ -165,6 +166,7 @@ export class WorkspaceRecorderImpl extends Disposable {
165166 repoRootUri : this . repoRootUri ,
166167 time : Date . now ( ) ,
167168 uuid : generateUuid ( ) ,
169+ revision : this . _revision ,
168170 } ) ;
169171 }
170172
@@ -199,10 +201,10 @@ export class WorkspaceRecorderImpl extends Disposable {
199201 this . _appendEntry ( { kind : 'closed' , id, time } ) ;
200202 }
201203
202- async handleOnDidChangeTextDocument ( time : number , documentUri : string , edit : StringEdit , newModelVersion : number ) : Promise < void > {
204+ async handleOnDidChangeTextDocument ( time : number , documentUri : string , edit : StringEdit , newModelVersion : number , metadata : IChangedMetadata | undefined ) : Promise < void > {
203205 const id = await this . _getId ( documentUri ) ;
204206 if ( id === undefined ) { return ; }
205- this . _appendEntry ( { kind : 'changed' , id, time, edit : serializeEdit ( edit ) , v : newModelVersion } ) ;
207+ this . _appendEntry ( { kind : 'changed' , id, time, edit : serializeEdit ( edit ) , v : newModelVersion , metadata } ) ;
206208 }
207209
208210 async handleOnDidFocusedDocumentChange ( time : number , documentUri : string ) : Promise < void > {
@@ -307,7 +309,7 @@ export class WorkspaceRecorderImpl extends Disposable {
307309
308310
309311type WorkspaceRecordingState = {
310- version : 3 ;
312+ version : 3 | 4 ;
311313 logCount : number ;
312314 documents : Record < /* relativePath */ string , { id : LogDocumentId ; lastHash : string } > ;
313315} | {
0 commit comments