Skip to content

Commit

Permalink
Merge pull request #7471 from davidwengier/SelfVersionedDocuments
Browse files Browse the repository at this point in the history
Don't use VS Code document versions anywhere
  • Loading branch information
davidwengier authored Aug 27, 2024
2 parents 115e4a1 + c87e57f commit c492b9a
Show file tree
Hide file tree
Showing 12 changed files with 20 additions and 37 deletions.
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,21 @@
- Debug from .csproj and .sln [#5876](https://github.com/dotnet/vscode-csharp/issues/5876)

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

# 2.45.17
* Fix check for rzls being present (PR: [#7462](https://github.com/dotnet/vscode-csharp/pull/7462))
* Bump Razor to 9.0.0-preview.24418.1 (PR: [#7456](https://github.com/dotnet/vscode-csharp/pull/7456))
* Don't add already known documents to the misc files project (#10753) (PR: [#10753](https://github.com/dotnet/razor/pull/10753))
* Remove ItemCollection from TagHelperDescriptorProviderContext (#10720) (PR: [#10720](https://github.com/dotnet/razor/pull/10720))
* Cohost inlay hint support (#10672) (PR: [#10672](https://github.com/dotnet/razor/pull/10672))
* Fix excerpt service to allow for multi line verbatim strings (#10675) (PR: [#10675](https://github.com/dotnet/razor/pull/10675))
* Fix attribute parsing recovery (#10620) (PR: [#10620](https://github.com/dotnet/razor/pull/10620))
* Turn off trailing whitespace triming in strings (#10646) (PR: [#10646](https://github.com/dotnet/razor/pull/10646))
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"defaults": {
"roslyn": "4.12.0-2.24422.6",
"omniSharp": "1.39.11",
"razor": "9.0.0-preview.24418.1",
"razor": "9.0.0-preview.24427.2",
"razorOmnisharp": "7.0.0-preview.23363.1",
"xamlTools": "17.12.35223.16"
},
Expand Down
6 changes: 0 additions & 6 deletions src/razor/src/csharp/csharpProjectedDocument.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ export class CSharpProjectedDocument implements IProjectedDocument {
private resolveProvisionalEditAt: number | undefined;
private ProvisionalDotPosition: Position | undefined;
private hostDocumentVersion: number | null = null;
private projectedDocumentVersion = 0;

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

public get projectedDocumentSyncVersion(): number {
return this.projectedDocumentVersion;
}

public get length(): number {
return this.content.length;
}
Expand Down Expand Up @@ -153,7 +148,6 @@ export class CSharpProjectedDocument implements IProjectedDocument {
}

private setContent(content: string) {
this.projectedDocumentVersion++;
this.content = content;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class CSharpProjectedDocumentContentProvider implements vscode.TextDocume
return this.onDidChangeEmitter.event;
}

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

const content = `${razorDocument.csharpDocument.getContent()}
// ${razorDocument.csharpDocument.projectedDocumentSyncVersion}`;
// ${razorDocument.csharpDocument.hostDocumentSyncVersion}`;

return content;
}
Expand Down
20 changes: 3 additions & 17 deletions src/razor/src/document/razorDocumentSynchronizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,10 @@ export class RazorDocumentSynchronizer {
const ehdv = expectedHostDocumentVersion;
this.logger.logVerbose(
`${logId} - Synchronizing '${documentKey}':
Currently at ${projectedDocument.hostDocumentSyncVersion}, synchronizing to version '${ehdv}'.
Current host document version: '${hostDocument.version}'
Current projected document version: '${projectedDocument.projectedDocumentSyncVersion}'`
Currently at ${projectedDocument.hostDocumentSyncVersion}, synchronizing to version '${ehdv}'.'`
);
}

if (hostDocument.version !== expectedHostDocumentVersion) {
if (this.logger.verboseEnabled) {
this.logger.logVerbose(
`${logId} - toHostDocumentVersion and hostDocument.version already out of date.`
);
}

// Already out-of-date. Allowing synchronizations for now to see if this actually causes any issues.
}

const context: SynchronizationContext = this.createSynchronizationContext(
documentKey,
projectedDocument,
Expand Down Expand Up @@ -84,7 +72,7 @@ export class RazorDocumentSynchronizer {

const projectedTextDocument = await vscode.workspace.openTextDocument(projectedDocument.uri);
const projectedTextDocumentVersion = this.getProjectedTextDocumentVersion(projectedTextDocument);
if (projectedDocument.projectedDocumentSyncVersion !== projectedTextDocumentVersion) {
if (projectedDocument.hostDocumentSyncVersion !== projectedTextDocumentVersion) {
if (this.logger.verboseEnabled) {
this.logger.logVerbose(
`${logId} - Projected text document not in sync with data type, waiting for update...
Expand Down Expand Up @@ -162,7 +150,6 @@ export class RazorDocumentSynchronizer {
logIdentifier: this.synchronizationIdentifier,
timeoutId,
toHostDocumentVersion,
hostDocumentVersion: hostDocument.version,
cancel: (reason) => {
for (const reject of rejectionsForCancel) {
reject(reason);
Expand Down Expand Up @@ -210,7 +197,7 @@ export class RazorDocumentSynchronizer {
}

for (const context of synchronizationContexts) {
if (context.projectedDocument.projectedDocumentSyncVersion === projectedTextDocumentVersion) {
if (context.projectedDocument.hostDocumentSyncVersion === projectedTextDocumentVersion) {
if (this.logger.verboseEnabled) {
const li = context.logIdentifier;
const ptdv = projectedTextDocumentVersion;
Expand Down Expand Up @@ -269,7 +256,6 @@ interface SynchronizationContext {
readonly projectedDocument: IProjectedDocument;
readonly logIdentifier: number;
readonly toHostDocumentVersion: number;
readonly hostDocumentVersion: number;
readonly timeoutId: NodeJS.Timer;
readonly projectedDocumentSynchronized: () => void;
readonly onProjectedDocumentSynchronized: Promise<void>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export class RazorDocumentHighlightProvider
continue;
}

if (document.version !== remappedResponse.hostDocumentVersion) {
if (projection.hostDocumentVersion !== remappedResponse.hostDocumentVersion) {
// This highlight result is for a different version of the text document, bail.
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion src/razor/src/hover/razorHoverProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export class RazorHoverProvider extends RazorLanguageFeatureBase implements vsco
return;
}

if (document.version !== remappedResponse.hostDocumentVersion) {
if (projection.hostDocumentVersion !== remappedResponse.hostDocumentVersion) {
// This hover result is for a different version of the text document, bail.
return;
}
Expand Down
6 changes: 0 additions & 6 deletions src/razor/src/html/htmlProjectedDocument.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export class HtmlProjectedDocument implements IProjectedDocument {
public readonly path: string;
private content = '';
private hostDocumentVersion: number | null = null;
private projectedDocumentVersion = 0;

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

public get projectedDocumentSyncVersion(): number {
return this.projectedDocumentVersion;
}

public get length(): number {
return this.content.length;
}
Expand Down Expand Up @@ -63,7 +58,6 @@ export class HtmlProjectedDocument implements IProjectedDocument {
}

private setContent(content: string) {
this.projectedDocumentVersion++;
this.content = content;
}
}
2 changes: 1 addition & 1 deletion src/razor/src/html/htmlProjectedDocumentContentProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export class HtmlProjectedDocumentContentProvider implements vscode.TextDocument
}

const content = `${razorDocument.htmlDocument.getContent()}
// ${razorDocument.htmlDocument.projectedDocumentSyncVersion}`;
// ${razorDocument.htmlDocument.hostDocumentSyncVersion}`;

return content;
}
Expand Down
1 change: 0 additions & 1 deletion src/razor/src/projection/IProjectedDocument.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export interface IProjectedDocument {
readonly path: string;
readonly uri: vscode.Uri;
readonly hostDocumentSyncVersion: number | null;
readonly projectedDocumentSyncVersion: number;
readonly length: number;
getContent(): string;
}
1 change: 1 addition & 0 deletions src/razor/src/projection/projectionResult.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ export interface ProjectionResult {
uri: vscode.Uri;
position: vscode.Position;
languageKind: LanguageKind;
hostDocumentVersion: number;
}
1 change: 1 addition & 0 deletions src/razor/src/razorLanguageFeatureBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export class RazorLanguageFeatureBase {
uri: projectedUri,
position: languageResponse.position,
languageKind: languageResponse.kind,
hostDocumentVersion: projectedDocument.hostDocumentSyncVersion,
} as ProjectionResult;
}
default:
Expand Down

0 comments on commit c492b9a

Please sign in to comment.