Skip to content

Commit c492b9a

Browse files
authored
Merge pull request #7471 from davidwengier/SelfVersionedDocuments
Don't use VS Code document versions anywhere
2 parents 115e4a1 + c87e57f commit c492b9a

12 files changed

+20
-37
lines changed

CHANGELOG.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,21 @@
44
- Debug from .csproj and .sln [#5876](https://github.com/dotnet/vscode-csharp/issues/5876)
55

66
# Latest
7+
* Bump Razor to 9.0.0-preview.24427.2 (PR: [#7471](https://github.com/dotnet/vscode-csharp/pull/7471))
8+
* Suppress unique ids (#10791) (PR: [#10791](https://github.com/dotnet/razor/pull/10791))
9+
* Self-versioned documents (#10747) (PR: [#10747](https://github.com/dotnet/razor/pull/10747))
10+
* Remove ItemCollection from CodeRenderingContext (#10764) (PR: [#10764](https://github.com/dotnet/razor/pull/10764))
11+
* Moving formatting service to common layer (#10761) (PR: [#10761](https://github.com/dotnet/razor/pull/10761))
12+
* Allow LSP and cohosting to provide specialized methods to get a syntax tree (#10765) (PR: [#10765](https://github.com/dotnet/razor/pull/10765))
13+
* Update NOTICE.txt (#10768) (PR: [#10768](https://github.com/dotnet/razor/pull/10768))
14+
* Allow @@ as a fallback (#10752) (PR: [#10752](https://github.com/dotnet/razor/pull/10752))
15+
* Support component rename from an end tag (#10762) (PR: [#10762](https://github.com/dotnet/razor/pull/10762))
716

817
# 2.45.17
918
* Fix check for rzls being present (PR: [#7462](https://github.com/dotnet/vscode-csharp/pull/7462))
1019
* Bump Razor to 9.0.0-preview.24418.1 (PR: [#7456](https://github.com/dotnet/vscode-csharp/pull/7456))
1120
* Don't add already known documents to the misc files project (#10753) (PR: [#10753](https://github.com/dotnet/razor/pull/10753))
1221
* Remove ItemCollection from TagHelperDescriptorProviderContext (#10720) (PR: [#10720](https://github.com/dotnet/razor/pull/10720))
13-
* Cohost inlay hint support (#10672) (PR: [#10672](https://github.com/dotnet/razor/pull/10672))
1422
* Fix excerpt service to allow for multi line verbatim strings (#10675) (PR: [#10675](https://github.com/dotnet/razor/pull/10675))
1523
* Fix attribute parsing recovery (#10620) (PR: [#10620](https://github.com/dotnet/razor/pull/10620))
1624
* Turn off trailing whitespace triming in strings (#10646) (PR: [#10646](https://github.com/dotnet/razor/pull/10646))

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"defaults": {
4040
"roslyn": "4.12.0-2.24422.6",
4141
"omniSharp": "1.39.11",
42-
"razor": "9.0.0-preview.24418.1",
42+
"razor": "9.0.0-preview.24427.2",
4343
"razorOmnisharp": "7.0.0-preview.23363.1",
4444
"xamlTools": "17.12.35223.16"
4545
},

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
}

0 commit comments

Comments
 (0)