Skip to content

Commit b2e1dd2

Browse files
authored
Failed to save 'index.tsx': The content of the file is newer (#5958)
Fixes #5943
1 parent cc79641 commit b2e1dd2

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/github/conflictResolutionCoordinator.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class MergeOutputProvider implements vscode.FileSystemProvider {
7979
clear(): void {
8080
const fileEvents: vscode.FileChangeEvent[] = [];
8181
for (const file of this._mergedFiles.keys()) {
82-
fileEvents.push({ uri: vscode.Uri.from({ scheme: Schemes.MergeOutput, path: file }), type: vscode.FileChangeType.Changed });
82+
fileEvents.push({ uri: vscode.Uri.from({ scheme: this._conflictResolutionModel.mergeScheme, path: file }), type: vscode.FileChangeType.Changed });
8383
this.updateFile(file, buffer.Buffer.from(ORIGINAL_FILE));
8484
}
8585
this._onDidChangeFile.fire(fileEvents);
@@ -124,7 +124,7 @@ export class ConflictResolutionCoordinator {
124124

125125
private register(): void {
126126
this._disposables.push(vscode.workspace.registerFileSystemProvider(Schemes.GithubPr, new GitHubContentProvider(this._githubRepositories), { isReadonly: true }));
127-
this._disposables.push(vscode.workspace.registerFileSystemProvider(Schemes.MergeOutput, this._mergeOutputProvider));
127+
this._disposables.push(vscode.workspace.registerFileSystemProvider(this._conflictResolutionModel.mergeScheme, this._mergeOutputProvider));
128128
this._disposables.push(vscode.commands.registerCommand('pr.resolveConflict', (conflict: Conflict) => {
129129
return this.openConflict(conflict);
130130
}));
@@ -184,7 +184,7 @@ export class ConflictResolutionCoordinator {
184184
const tabsToClose: vscode.Tab[] = [];
185185
for (const group of vscode.window.tabGroups.all) {
186186
for (const tab of group.tabs) {
187-
if ((tab.input instanceof vscode.TabInputTextMerge) && (tab.input.result.scheme === Schemes.MergeOutput)) {
187+
if ((tab.input instanceof vscode.TabInputTextMerge) && (tab.input.result.scheme === this._conflictResolutionModel.mergeScheme)) {
188188
tabsToClose.push(tab);
189189
}
190190
}

src/github/conflictResolutionModel.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6+
import { randomUUID } from 'crypto';
67
import * as vscode from 'vscode';
78
import { Schemes, toGitHubUri } from '../common/uri';
89

@@ -26,6 +27,7 @@ export class ConflictResolutionModel {
2627
private readonly _resolvedConflicts: Map<string, ResolvedConflict> = new Map();
2728
private readonly _onAddedResolution: vscode.EventEmitter<void> = new vscode.EventEmitter<void>();
2829
public readonly onAddedResolution: vscode.Event<void> = this._onAddedResolution.event;
30+
public readonly mergeScheme = `${Schemes.MergeOutput}-${randomUUID()}`;
2931

3032
constructor(public readonly startingConflicts: Conflict[], public readonly repositoryName: string, public readonly prBaseOwner: string,
3133
public readonly latestPrBaseSha: string,
@@ -67,7 +69,7 @@ export class ConflictResolutionModel {
6769
}
6870

6971
public mergeOutputUri(conflict: Conflict) {
70-
return vscode.Uri.parse(`${Schemes.MergeOutput}:/${conflict.prHeadFilePath}`);
72+
return vscode.Uri.parse(`${this.mergeScheme}:/${conflict.prHeadFilePath}`);
7173
}
7274

7375
public mergeBaseUri(conflict: { prHeadFilePath: string }): vscode.Uri {

0 commit comments

Comments
 (0)