Skip to content

Commit 77133ad

Browse files
committed
Don't use VS Code document versions anywhere
1 parent 1ea3aff commit 77133ad

10 files changed

+10
-35
lines changed

src/razor/src/csharp/csharpProjectedDocument.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ export class CSharpProjectedDocument implements IProjectedDocument {
1919
private resolveProvisionalEditAt: number | undefined;
2020
private ProvisionalDotPosition: Position | undefined;
2121
private hostDocumentVersion: number | null = null;
22-
private projectedDocumentVersion = 0;
2322

2423
public constructor(public readonly uri: vscode.Uri) {
2524
this.path = getUriPath(uri);
@@ -29,10 +28,6 @@ export class CSharpProjectedDocument implements IProjectedDocument {
2928
return this.hostDocumentVersion;
3029
}
3130

32-
public get projectedDocumentSyncVersion(): number {
33-
return this.projectedDocumentVersion;
34-
}
35-
3631
public get length(): number {
3732
return this.content.length;
3833
}
@@ -153,7 +148,6 @@ export class CSharpProjectedDocument implements IProjectedDocument {
153148
}
154149

155150
private setContent(content: string) {
156-
this.projectedDocumentVersion++;
157151
this.content = content;
158152
}
159153
}

src/razor/src/csharp/csharpProjectedDocumentContentProvider.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export class CSharpProjectedDocumentContentProvider implements vscode.TextDocume
2929
return this.onDidChangeEmitter.event;
3030
}
3131

32-
public async provideTextDocumentContent(uri: vscode.Uri) {
32+
public provideTextDocumentContent(uri: vscode.Uri) {
3333
const razorDocument = this.findRazorDocument(uri);
3434
if (!razorDocument) {
3535
// Document was removed from the document manager, meaning there's no more content for this
@@ -46,7 +46,7 @@ export class CSharpProjectedDocumentContentProvider implements vscode.TextDocume
4646
}
4747

4848
const content = `${razorDocument.csharpDocument.getContent()}
49-
// ${razorDocument.csharpDocument.projectedDocumentSyncVersion}`;
49+
// ${razorDocument.csharpDocument.hostDocumentSyncVersion}`;
5050

5151
return content;
5252
}

src/razor/src/document/razorDocumentSynchronizer.ts

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -41,22 +41,10 @@ export class RazorDocumentSynchronizer {
4141
const ehdv = expectedHostDocumentVersion;
4242
this.logger.logVerbose(
4343
`${logId} - Synchronizing '${documentKey}':
44-
Currently at ${projectedDocument.hostDocumentSyncVersion}, synchronizing to version '${ehdv}'.
45-
Current host document version: '${hostDocument.version}'
46-
Current projected document version: '${projectedDocument.projectedDocumentSyncVersion}'`
44+
Currently at ${projectedDocument.hostDocumentSyncVersion}, synchronizing to version '${ehdv}'.'`
4745
);
4846
}
4947

50-
if (hostDocument.version !== expectedHostDocumentVersion) {
51-
if (this.logger.verboseEnabled) {
52-
this.logger.logVerbose(
53-
`${logId} - toHostDocumentVersion and hostDocument.version already out of date.`
54-
);
55-
}
56-
57-
// Already out-of-date. Allowing synchronizations for now to see if this actually causes any issues.
58-
}
59-
6048
const context: SynchronizationContext = this.createSynchronizationContext(
6149
documentKey,
6250
projectedDocument,
@@ -84,7 +72,7 @@ export class RazorDocumentSynchronizer {
8472

8573
const projectedTextDocument = await vscode.workspace.openTextDocument(projectedDocument.uri);
8674
const projectedTextDocumentVersion = this.getProjectedTextDocumentVersion(projectedTextDocument);
87-
if (projectedDocument.projectedDocumentSyncVersion !== projectedTextDocumentVersion) {
75+
if (projectedDocument.hostDocumentSyncVersion !== projectedTextDocumentVersion) {
8876
if (this.logger.verboseEnabled) {
8977
this.logger.logVerbose(
9078
`${logId} - Projected text document not in sync with data type, waiting for update...
@@ -162,7 +150,6 @@ export class RazorDocumentSynchronizer {
162150
logIdentifier: this.synchronizationIdentifier,
163151
timeoutId,
164152
toHostDocumentVersion,
165-
hostDocumentVersion: hostDocument.version,
166153
cancel: (reason) => {
167154
for (const reject of rejectionsForCancel) {
168155
reject(reason);
@@ -210,7 +197,7 @@ export class RazorDocumentSynchronizer {
210197
}
211198

212199
for (const context of synchronizationContexts) {
213-
if (context.projectedDocument.projectedDocumentSyncVersion === projectedTextDocumentVersion) {
200+
if (context.projectedDocument.hostDocumentSyncVersion === projectedTextDocumentVersion) {
214201
if (this.logger.verboseEnabled) {
215202
const li = context.logIdentifier;
216203
const ptdv = projectedTextDocumentVersion;
@@ -269,7 +256,6 @@ interface SynchronizationContext {
269256
readonly projectedDocument: IProjectedDocument;
270257
readonly logIdentifier: number;
271258
readonly toHostDocumentVersion: number;
272-
readonly hostDocumentVersion: number;
273259
readonly timeoutId: NodeJS.Timer;
274260
readonly projectedDocumentSynchronized: () => void;
275261
readonly onProjectedDocumentSynchronized: Promise<void>;

src/razor/src/documentHighlight/razorDocumentHighlightProvider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export class RazorDocumentHighlightProvider
4646
continue;
4747
}
4848

49-
if (document.version !== remappedResponse.hostDocumentVersion) {
49+
if (projection.hostDocumentVersion !== remappedResponse.hostDocumentVersion) {
5050
// This highlight result is for a different version of the text document, bail.
5151
continue;
5252
}

src/razor/src/hover/razorHoverProvider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export class RazorHoverProvider extends RazorLanguageFeatureBase implements vsco
4848
return;
4949
}
5050

51-
if (document.version !== remappedResponse.hostDocumentVersion) {
51+
if (projection.hostDocumentVersion !== remappedResponse.hostDocumentVersion) {
5252
// This hover result is for a different version of the text document, bail.
5353
return;
5454
}

src/razor/src/html/htmlProjectedDocument.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ export class HtmlProjectedDocument implements IProjectedDocument {
1212
public readonly path: string;
1313
private content = '';
1414
private hostDocumentVersion: number | null = null;
15-
private projectedDocumentVersion = 0;
1615

1716
public constructor(public readonly uri: vscode.Uri) {
1817
this.path = getUriPath(uri);
@@ -22,10 +21,6 @@ export class HtmlProjectedDocument implements IProjectedDocument {
2221
return this.hostDocumentVersion;
2322
}
2423

25-
public get projectedDocumentSyncVersion(): number {
26-
return this.projectedDocumentVersion;
27-
}
28-
2924
public get length(): number {
3025
return this.content.length;
3126
}
@@ -63,7 +58,6 @@ export class HtmlProjectedDocument implements IProjectedDocument {
6358
}
6459

6560
private setContent(content: string) {
66-
this.projectedDocumentVersion++;
6761
this.content = content;
6862
}
6963
}

src/razor/src/html/htmlProjectedDocumentContentProvider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export class HtmlProjectedDocumentContentProvider implements vscode.TextDocument
4646
}
4747

4848
const content = `${razorDocument.htmlDocument.getContent()}
49-
// ${razorDocument.htmlDocument.projectedDocumentSyncVersion}`;
49+
// ${razorDocument.htmlDocument.hostDocumentSyncVersion}`;
5050

5151
return content;
5252
}

src/razor/src/projection/IProjectedDocument.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ export interface IProjectedDocument {
99
readonly path: string;
1010
readonly uri: vscode.Uri;
1111
readonly hostDocumentSyncVersion: number | null;
12-
readonly projectedDocumentSyncVersion: number;
1312
readonly length: number;
1413
getContent(): string;
1514
}

src/razor/src/projection/projectionResult.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ export interface ProjectionResult {
1010
uri: vscode.Uri;
1111
position: vscode.Position;
1212
languageKind: LanguageKind;
13+
hostDocumentVersion: number;
1314
}

src/razor/src/razorLanguageFeatureBase.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ export class RazorLanguageFeatureBase {
6464
uri: projectedUri,
6565
position: languageResponse.position,
6666
languageKind: languageResponse.kind,
67+
hostDocumentVersion: projectedDocument.hostDocumentSyncVersion,
6768
} as ProjectionResult;
6869
}
6970
default:

0 commit comments

Comments
 (0)