Skip to content

Commit ffa55d0

Browse files
authored
Improve triggering of AttemptedEdit source control action (#1380)
1 parent 5e2b64d commit ffa55d0

File tree

2 files changed

+5
-16
lines changed

2 files changed

+5
-16
lines changed

src/commands/studio.ts

-13
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,6 @@ function getOtherStudioActionLabel(action: OtherStudioAction): string {
6565
return label;
6666
}
6767

68-
// Used to avoid triggering the edit listener when files are reloaded by an extension
69-
const suppressEditListenerMap = new Map<string, boolean>();
70-
7168
export class StudioActions {
7269
private uri: vscode.Uri;
7370
private api: AtelierAPI;
@@ -336,8 +333,6 @@ export class StudioActions {
336333
const actionToProcess: UserAction = data.result.content.pop();
337334

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

@@ -349,7 +344,6 @@ export class StudioActions {
349344
this.projectEditAnswer = "-1";
350345
} else if (this.uri) {
351346
// Only revert if we have a URI
352-
suppressEditListenerMap.set(this.uri.toString(), true);
353347
await vscode.commands.executeCommand("workbench.action.files.revert", this.uri);
354348
}
355349
}
@@ -362,7 +356,6 @@ export class StudioActions {
362356
if (action.label === attemptedEditLabel) {
363357
if (answer != "1" && this.uri) {
364358
// Only revert if we have a URI
365-
suppressEditListenerMap.set(this.uri.toString(), true);
366359
await vscode.commands.executeCommand("workbench.action.files.revert", this.uri);
367360
}
368361
if (this.name.toUpperCase().endsWith(".PRJ")) {
@@ -455,12 +448,6 @@ export class StudioActions {
455448
label: getOtherStudioActionLabel(action),
456449
};
457450
if (action === OtherStudioAction.AttemptedEdit) {
458-
// Check to see if this "attempted edit" was an action by this extension due to a reload.
459-
// There's no way to detect at a higher level from the event.
460-
if (suppressEditListenerMap.has(this.uri.toString())) {
461-
suppressEditListenerMap.delete(this.uri.toString());
462-
return;
463-
}
464451
const query = "select * from %Atelier_v1_Utils.Extension_GetStatus(?)";
465452
this.api.actionQuery(query, [this.name]).then((statusObj) => {
466453
const docStatus = statusObj.result.content.pop();

src/extension.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -849,9 +849,11 @@ export async function activate(context: vscode.ExtensionContext): Promise<any> {
849849
}),
850850
vscode.workspace.onDidChangeTextDocument((event) => {
851851
if (
852-
event.contentChanges.length !== 0 &&
853-
event.document.uri.scheme === FILESYSTEM_SCHEMA &&
854-
!event.document.isDirty
852+
event.document.uri.scheme == FILESYSTEM_SCHEMA &&
853+
// These two expressions will both be true only for
854+
// the edit that makes a document go from clean to dirty
855+
event.contentChanges.length == 0 &&
856+
event.document.isDirty
855857
) {
856858
fireOtherStudioAction(OtherStudioAction.AttemptedEdit, event.document.uri);
857859
}

0 commit comments

Comments
 (0)