Skip to content

Commit 53ca75b

Browse files
Andrew Hallgithub-actions
authored andcommitted
Only ignore for sending dynamic updates. Keep changes in system for synchronization
1 parent 36a5ce2 commit 53ca75b

File tree

3 files changed

+15
-19
lines changed

3 files changed

+15
-19
lines changed

src/razor/src/document/IRazorDocumentChangeEvent.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6+
import { ServerTextChange } from '../rpc/serverTextChange';
67
import { IRazorDocument } from './IRazorDocument';
78
import { RazorDocumentChangeKind } from './razorDocumentChangeKind';
89

910
export interface IRazorDocumentChangeEvent {
1011
readonly document: IRazorDocument;
1112
readonly kind: RazorDocumentChangeKind;
13+
readonly changes: ServerTextChange[];
1214
}

src/razor/src/document/razorDocumentManager.ts

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { createDocument } from './razorDocumentFactory';
2020
import { razorInitializeCommand } from '../../../lsptoolshost/razor/razorCommands';
2121
import { PlatformInformation } from '../../../shared/platform';
2222
import { v4 as uuidv4 } from 'uuid';
23+
import { ServerTextChange } from '../rpc/serverTextChange';
2324

2425
export class RazorDocumentManager implements IRazorDocumentManager {
2526
public roslynActivated = false;
@@ -158,7 +159,7 @@ export class RazorDocumentManager implements IRazorDocumentManager {
158159

159160
const document = this._getDocument(uri);
160161

161-
this.notifyDocumentChange(document, RazorDocumentChangeKind.opened);
162+
this.notifyDocumentChange(document, RazorDocumentChangeKind.opened, []);
162163
}
163164

164165
public async ensureRazorInitialized() {
@@ -189,7 +190,7 @@ export class RazorDocumentManager implements IRazorDocumentManager {
189190
}
190191
}
191192

192-
this.notifyDocumentChange(document, RazorDocumentChangeKind.closed);
193+
this.notifyDocumentChange(document, RazorDocumentChangeKind.closed, []);
193194
}
194195

195196
private addDocument(uri: vscode.Uri): IRazorDocument {
@@ -203,7 +204,7 @@ export class RazorDocumentManager implements IRazorDocumentManager {
203204
document = createDocument(uri);
204205
this.razorDocuments[document.path] = document;
205206

206-
this.notifyDocumentChange(document, RazorDocumentChangeKind.added);
207+
this.notifyDocumentChange(document, RazorDocumentChangeKind.added, []);
207208

208209
return document;
209210
}
@@ -212,7 +213,7 @@ export class RazorDocumentManager implements IRazorDocumentManager {
212213
const document = this._getDocument(uri);
213214
delete this.razorDocuments[document.path];
214215

215-
this.notifyDocumentChange(document, RazorDocumentChangeKind.removed);
216+
this.notifyDocumentChange(document, RazorDocumentChangeKind.removed, []);
216217
}
217218

218219
private findDocument(path: string) {
@@ -237,16 +238,6 @@ export class RazorDocumentManager implements IRazorDocumentManager {
237238
);
238239
}
239240

240-
if (updateBufferRequest.changes.length === 0 && !updateBufferRequest.previousWasEmpty) {
241-
if (this.logger.verboseEnabled) {
242-
this.logger.logVerbose(
243-
`Update for '${updateBufferRequest.hostDocumentFilePath}' was empty. This shouldn't happen because it means the language server is doing extra work.`
244-
);
245-
}
246-
247-
return;
248-
}
249-
250241
const hostDocumentUri = vscode.Uri.file(updateBufferRequest.hostDocumentFilePath);
251242
const document = this._getDocument(hostDocumentUri);
252243
const projectedDocument = document.csharpDocument;
@@ -277,7 +268,7 @@ export class RazorDocumentManager implements IRazorDocumentManager {
277268
updateBufferRequest.encodingCodePage
278269
);
279270

280-
this.notifyDocumentChange(document, RazorDocumentChangeKind.csharpChanged);
271+
this.notifyDocumentChange(document, RazorDocumentChangeKind.csharpChanged, updateBufferRequest.changes);
281272
} else {
282273
this.logger.logWarning(
283274
'Failed to update the C# document buffer. This is unexpected and may result in incorrect C# interactions.'
@@ -320,24 +311,27 @@ export class RazorDocumentManager implements IRazorDocumentManager {
320311

321312
htmlProjectedDocument.update(updateBufferRequest.changes, updateBufferRequest.hostDocumentVersion);
322313

323-
this.notifyDocumentChange(document, RazorDocumentChangeKind.htmlChanged);
314+
this.notifyDocumentChange(document, RazorDocumentChangeKind.htmlChanged, updateBufferRequest.changes);
324315
} else {
325316
this.logger.logWarning(
326317
'Failed to update the HTML document buffer. This is unexpected and may result in incorrect HTML interactions.'
327318
);
328319
}
329320
}
330321

331-
private notifyDocumentChange(document: IRazorDocument, kind: RazorDocumentChangeKind) {
322+
private notifyDocumentChange(document: IRazorDocument, kind: RazorDocumentChangeKind, changes: ServerTextChange[]) {
332323
if (this.logger.verboseEnabled) {
333324
this.logger.logVerbose(
334-
`Notifying document '${getUriPath(document.uri)}' changed '${RazorDocumentChangeKind[kind]}'`
325+
`Notifying document '${getUriPath(document.uri)}' changed '${RazorDocumentChangeKind[kind]}' with '${
326+
changes.length
327+
}' changes.`
335328
);
336329
}
337330

338331
const args: IRazorDocumentChangeEvent = {
339332
document,
340333
kind,
334+
changes,
341335
};
342336

343337
this.onChangeEmitter.fire(args);

src/razor/src/dynamicFile/dynamicFileInfoHandler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export class DynamicFileInfoHandler {
4040
}
4141
);
4242
this.documentManager.onChange(async (e) => {
43-
if (e.kind == RazorDocumentChangeKind.csharpChanged && !e.document.isOpen) {
43+
if (e.kind == RazorDocumentChangeKind.csharpChanged && !e.document.isOpen && e.changes.length > 0) {
4444
const uriString = UriConverter.serialize(e.document.uri);
4545
const identifier = TextDocumentIdentifier.create(uriString);
4646
await vscode.commands.executeCommand(

0 commit comments

Comments
 (0)