Skip to content

Commit

Permalink
Improve triggering of AttemptedEdit source control action (#1380)
Browse files Browse the repository at this point in the history
  • Loading branch information
isc-bsaviano authored Jul 3, 2024
1 parent 5e2b64d commit ffa55d0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 16 deletions.
13 changes: 0 additions & 13 deletions src/commands/studio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,6 @@ function getOtherStudioActionLabel(action: OtherStudioAction): string {
return label;
}

// Used to avoid triggering the edit listener when files are reloaded by an extension
const suppressEditListenerMap = new Map<string, boolean>();

export class StudioActions {
private uri: vscode.Uri;
private api: AtelierAPI;
Expand Down Expand Up @@ -336,8 +333,6 @@ export class StudioActions {
const actionToProcess: UserAction = data.result.content.pop();

if (actionToProcess.reload) {
// Avoid the reload triggering the edit listener here
suppressEditListenerMap.set(this.uri.toString(), true);
await vscode.commands.executeCommand("workbench.action.files.revert", this.uri);
}

Expand All @@ -349,7 +344,6 @@ export class StudioActions {
this.projectEditAnswer = "-1";
} else if (this.uri) {
// Only revert if we have a URI
suppressEditListenerMap.set(this.uri.toString(), true);
await vscode.commands.executeCommand("workbench.action.files.revert", this.uri);
}
}
Expand All @@ -362,7 +356,6 @@ export class StudioActions {
if (action.label === attemptedEditLabel) {
if (answer != "1" && this.uri) {
// Only revert if we have a URI
suppressEditListenerMap.set(this.uri.toString(), true);
await vscode.commands.executeCommand("workbench.action.files.revert", this.uri);
}
if (this.name.toUpperCase().endsWith(".PRJ")) {
Expand Down Expand Up @@ -455,12 +448,6 @@ export class StudioActions {
label: getOtherStudioActionLabel(action),
};
if (action === OtherStudioAction.AttemptedEdit) {
// Check to see if this "attempted edit" was an action by this extension due to a reload.
// There's no way to detect at a higher level from the event.
if (suppressEditListenerMap.has(this.uri.toString())) {
suppressEditListenerMap.delete(this.uri.toString());
return;
}
const query = "select * from %Atelier_v1_Utils.Extension_GetStatus(?)";
this.api.actionQuery(query, [this.name]).then((statusObj) => {
const docStatus = statusObj.result.content.pop();
Expand Down
8 changes: 5 additions & 3 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -849,9 +849,11 @@ export async function activate(context: vscode.ExtensionContext): Promise<any> {
}),
vscode.workspace.onDidChangeTextDocument((event) => {
if (
event.contentChanges.length !== 0 &&
event.document.uri.scheme === FILESYSTEM_SCHEMA &&
!event.document.isDirty
event.document.uri.scheme == FILESYSTEM_SCHEMA &&
// These two expressions will both be true only for
// the edit that makes a document go from clean to dirty
event.contentChanges.length == 0 &&
event.document.isDirty
) {
fireOtherStudioAction(OtherStudioAction.AttemptedEdit, event.document.uri);
}
Expand Down

0 comments on commit ffa55d0

Please sign in to comment.