Skip to content

Commit 5b3e0eb

Browse files
author
Andrew Hall (METAL)
committed
Pass multiple updates as sets of edits
1 parent 0b09369 commit 5b3e0eb

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

src/razor/src/dynamicFile/dynamicFileInfoHandler.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { UriConverter } from '../../../lsptoolshost/uriConverter';
88
import { RazorDocumentManager } from '../document/razorDocumentManager';
99
import { RazorLogger } from '../razorLogger';
1010
import { ProvideDynamicFileParams } from './provideDynamicFileParams';
11-
import { ProvideDynamicFileResponse } from './provideDynamicFileResponse';
11+
import { ProvideDynamicFileResponse, DynamicFileUpdate } from './provideDynamicFileResponse';
1212
import { RemoveDynamicFileParams } from './removeDynamicFileParams';
1313
import { CSharpProjectedDocument } from '../csharp/csharpProjectedDocument';
1414
import { RazorDocumentChangeKind } from '../document/razorDocumentChangeKind';
@@ -83,9 +83,11 @@ export class DynamicFileInfoHandler {
8383
},
8484
};
8585

86+
const update = new DynamicFileUpdate([change]);
87+
8688
return new ProvideDynamicFileResponse(
8789
request.razorDocument,
88-
[change],
90+
[update],
8991
csharpDocument.checksum,
9092
csharpDocument.checksumAlgorithm,
9193
csharpDocument.encodingCodePage
@@ -108,11 +110,11 @@ export class DynamicFileInfoHandler {
108110
// Closed documents provide edits since the last time they were requested since
109111
// there is no open buffer in vscode corresponding to the csharp content.
110112
const response = csharpDocument.applyEdits();
111-
const changes = response.edits?.map((e) => e.changes).reduce((a, b) => a.concat(b)) ?? null;
113+
const updates = response.edits?.map((e) => new DynamicFileUpdate(e.changes)) ?? null;
112114

113115
return new ProvideDynamicFileResponse(
114116
{ uri: virtualCsharpUri },
115-
changes,
117+
updates,
116118
response.originalChecksum,
117119
response.originalChecksumAlgorithm,
118120
response.originalEncodingCodePage

src/razor/src/dynamicFile/provideDynamicFileResponse.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,13 @@ import { ServerTextChange } from '../rpc/serverTextChange';
1010
export class ProvideDynamicFileResponse {
1111
constructor(
1212
public readonly csharpDocument: TextDocumentIdentifier | null,
13-
public readonly edits: ServerTextChange[] | null,
13+
public readonly updates: DynamicFileUpdate[] | null,
1414
public readonly checksum: string,
1515
public readonly checksumAlgorithm: number,
1616
public readonly encodingCodePage: number | null
1717
) {}
1818
}
19+
20+
export class DynamicFileUpdate {
21+
constructor(public readonly edits: ServerTextChange[]) {}
22+
}

0 commit comments

Comments
 (0)