@@ -19,9 +19,9 @@ export class CSharpProjectedDocument implements IProjectedDocument {
1919 private resolveProvisionalEditAt : number | undefined ;
2020 private ProvisionalDotPosition : Position | undefined ;
2121 private hostDocumentVersion : number | null = null ;
22- private updates : Update [ ] | null = null ;
23- private _checksum : Uint8Array = new Uint8Array ( ) ;
24- private _checksumAlgorithm : number = 0 ;
22+ private updates : CSharpDocumentUpdate [ ] | null = null ;
23+ private _checksum : string = '' ;
24+ private _checksumAlgorithm : number = 1 ; // Default to Sha1
2525 private _encodingCodePage : number | null = null ;
2626
2727 public constructor ( public readonly uri : vscode . Uri ) {
@@ -36,7 +36,11 @@ export class CSharpProjectedDocument implements IProjectedDocument {
3636 return this . content . length ;
3737 }
3838
39- public get checksum ( ) : Uint8Array {
39+ public clear ( ) {
40+ this . setContent ( '' ) ;
41+ }
42+
43+ public get checksum ( ) : string {
4044 return this . _checksum ;
4145 }
4246
@@ -48,15 +52,11 @@ export class CSharpProjectedDocument implements IProjectedDocument {
4852 return this . _encodingCodePage ;
4953 }
5054
51- public clear ( ) {
52- this . setContent ( '' ) ;
53- }
54-
5555 public update (
5656 hostDocumentIsOpen : boolean ,
5757 edits : ServerTextChange [ ] ,
5858 hostDocumentVersion : number ,
59- checksum : Uint8Array ,
59+ checksum : string ,
6060 checksumAlgorithm : number ,
6161 encodingCodePage : number | null
6262 ) {
@@ -73,35 +73,45 @@ export class CSharpProjectedDocument implements IProjectedDocument {
7373 }
7474
7575 this . updateContent ( edits ) ;
76+ this . _checksum = checksum ;
77+ this . _checksumAlgorithm = checksumAlgorithm ;
78+ this . _encodingCodePage = encodingCodePage ;
7679 } else {
80+ const update = new CSharpDocumentUpdate ( edits , checksum , checksumAlgorithm , encodingCodePage ) ;
81+
7782 if ( this . updates ) {
78- this . updates = this . updates . concat ( new Update ( edits ) ) ;
83+ this . updates = this . updates . concat ( update ) ;
7984 } else {
80- this . updates = [ new Update ( edits ) ] ;
85+ this . updates = [ update ] ;
8186 }
8287 }
8388
84- this . _checksum = checksum ;
85- this . _checksumAlgorithm = checksumAlgorithm ;
86- this . _encodingCodePage = encodingCodePage ;
8789 this . hostDocumentVersion = hostDocumentVersion ;
8890 }
8991
90- public getAndApplyEdits ( ) {
92+ public applyEdits ( ) : ApplyEditsResponse {
9193 const updates = this . updates ;
9294 this . updates = null ;
9395
96+ const originalChecksum = this . _checksum ;
97+ const originalChecksumAlgorithm = this . _checksumAlgorithm ;
98+ const originalEncodingCodePage = this . _encodingCodePage ;
99+
94100 if ( updates ) {
95- let changes : ServerTextChange [ ] = [ ] ;
96101 for ( const update of updates ) {
97102 this . updateContent ( update . changes ) ;
98- changes = changes . concat ( update . changes ) ;
103+ this . _checksum = update . checksum ;
104+ this . _checksumAlgorithm = update . checksumAlgorithm ;
105+ this . _encodingCodePage = update . encodingCodePage ;
99106 }
100-
101- return changes ;
102107 }
103108
104- return null ;
109+ return {
110+ edits : updates ,
111+ originalChecksum : originalChecksum ,
112+ originalChecksumAlgorithm : originalChecksumAlgorithm ,
113+ originalEncodingCodePage : originalEncodingCodePage ,
114+ } ;
105115 }
106116
107117 public getContent ( ) {
@@ -216,6 +226,18 @@ export class CSharpProjectedDocument implements IProjectedDocument {
216226 }
217227}
218228
219- class Update {
220- constructor ( public readonly changes : ServerTextChange [ ] ) { }
229+ export class CSharpDocumentUpdate {
230+ constructor (
231+ public readonly changes : ServerTextChange [ ] ,
232+ public readonly checksum : string ,
233+ public readonly checksumAlgorithm : number ,
234+ public readonly encodingCodePage : number | null
235+ ) { }
236+ }
237+
238+ export interface ApplyEditsResponse {
239+ edits : CSharpDocumentUpdate [ ] | null ;
240+ originalChecksum : string ;
241+ originalChecksumAlgorithm : number ;
242+ originalEncodingCodePage : number | null ;
221243}
0 commit comments