Skip to content

Commit 393774e

Browse files
authored
Trigger server-side source control OpenedDocument UserAction after a project is modified (#1685)
1 parent cae8b53 commit 393774e

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

src/commands/project.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -888,6 +888,11 @@ export async function modifyProject(
888888
await api.actionQuery("UPDATE %Studio.Project SET LastModified = NOW() WHERE Name = ?", [project]).catch(() => {
889889
// Swallow error because VS Code doesn't care about the timestamp
890890
});
891+
// "Re-open" the project to signal to the source control class that it should reconcile the server version
892+
// with the version stored in the source control system. This effectively acts like OnAfterSave().
893+
await new StudioActions().fireProjectUserAction(api, project, OtherStudioAction.OpenedDocument).catch(() => {
894+
// The modification has already been completed so there's no point in showing this error
895+
});
891896
}
892897
} catch (error) {
893898
handleError(error, `Failed to modify project '${project}'.`);
@@ -1168,6 +1173,12 @@ export async function modifyProjectMetadata(nodeOrUri: NodeBase | vscode.Uri | u
11681173
project,
11691174
]);
11701175

1176+
// "Re-open" the project to signal to the source control class that it should reconcile the server version
1177+
// with the version stored in the source control system. This effectively acts like OnAfterSave().
1178+
await new StudioActions().fireProjectUserAction(api, project, OtherStudioAction.OpenedDocument).catch(() => {
1179+
// The modification has already been completed so there's no point in showing this error
1180+
});
1181+
11711182
// Refesh the explorer
11721183
projectsExplorerProvider.refresh();
11731184
} catch (error) {

src/commands/studio.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,8 @@ export class StudioActions {
320320
this.api
321321
.actionQuery(query, parameters)
322322
.then(async (data) => {
323-
if (action.save && action.id != "6" && !this.name.endsWith(".PRJ") && this.uri) {
323+
const isPrj = this.name.toUpperCase().endsWith(".PRJ");
324+
if (action.save && action.id != "6" && !isPrj && this.uri) {
324325
// Save the requested documents.
325326
// Ignore the save flag if this is a project or bulk import action.
326327
const bitString: string = action.save.toString().padStart(3, "0");
@@ -354,14 +355,14 @@ export class StudioActions {
354355
}
355356
const actionToProcess: UserAction = data.result.content.pop();
356357

357-
if (actionToProcess.reload) {
358+
if (actionToProcess.reload && !isPrj) {
358359
await vscode.commands.executeCommand("workbench.action.files.revert", this.uri);
359360
}
360361

361362
const attemptedEditLabel = getOtherStudioActionLabel(OtherStudioAction.AttemptedEdit);
362363
if (afterUserAction && actionToProcess.errorText !== "") {
363364
if (action.label === attemptedEditLabel) {
364-
if (this.name.toUpperCase().endsWith(".PRJ")) {
365+
if (isPrj) {
365366
// Store the "answer" so the caller knows there was an error
366367
this.projectEditAnswer = "-1";
367368
} else if (this.uri) {
@@ -380,7 +381,7 @@ export class StudioActions {
380381
// Only revert if we have a URI
381382
await vscode.commands.executeCommand("workbench.action.files.revert", this.uri);
382383
}
383-
if (this.name.toUpperCase().endsWith(".PRJ")) {
384+
if (isPrj) {
384385
// Store the answer. No answer means "allow the edit".
385386
this.projectEditAnswer = answer ?? "1";
386387
}

0 commit comments

Comments
 (0)