|
1 | 1 | import * as vscode from "vscode"; |
2 | 2 | import { AtelierAPI } from "../api"; |
3 | 3 | import { config, FILESYSTEM_SCHEMA } from "../extension"; |
4 | | -import { outputChannel, outputConsole, currentFile, getServerName } from "../utils"; |
| 4 | +import { outputChannel, outputConsole, getServerName } from "../utils"; |
5 | 5 | import { DocumentContentProvider } from "../providers/DocumentContentProvider"; |
6 | 6 | import { ClassNode } from "../explorer/models/classNode"; |
7 | 7 | import { PackageNode } from "../explorer/models/packageNode"; |
8 | 8 | import { RoutineNode } from "../explorer/models/routineNode"; |
9 | 9 | import { NodeBase } from "../explorer/models/nodeBase"; |
10 | | -import { importAndCompile, loadChanges } from "./compile"; |
| 10 | +import { importAndCompile } from "./compile"; |
11 | 11 |
|
12 | 12 | export let documentBeingProcessed: vscode.TextDocument = null; |
13 | 13 |
|
@@ -272,34 +272,38 @@ class StudioActions { |
272 | 272 | const actionToProcess = data.result.content.pop(); |
273 | 273 |
|
274 | 274 | if (actionToProcess.reload) { |
275 | | - const document = vscode.window.activeTextEditor.document; |
276 | | - const file = currentFile(document); |
277 | 275 | // Avoid the reload triggering the edit listener here |
278 | | - suppressEditListenerMap.set(file.uri.toString(), true); |
279 | | - await loadChanges([file]); |
| 276 | + suppressEditListenerMap.set(this.uri.toString(), true); |
| 277 | + await vscode.commands.executeCommand("workbench.action.files.revert", this.uri); |
280 | 278 | } |
281 | 279 |
|
282 | 280 | // CSP pages should not have a progress bar |
283 | 281 | if (actionToProcess.action === 2) { |
284 | 282 | resolve(); |
285 | 283 | } |
286 | | - return actionToProcess; |
287 | | - }) |
288 | | - .then((actionToProcess) => { |
| 284 | + |
| 285 | + const attemptedEditLabel = getOtherStudioActionLabel(OtherStudioAction.AttemptedEdit); |
289 | 286 | if (afterUserAction && actionToProcess.errorText !== "") { |
| 287 | + if (action.label === attemptedEditLabel) { |
| 288 | + suppressEditListenerMap.set(this.uri.toString(), true); |
| 289 | + await vscode.commands.executeCommand("workbench.action.files.revert", this.uri); |
| 290 | + } |
290 | 291 | outputChannel.appendLine(actionToProcess.errorText); |
291 | 292 | outputChannel.show(); |
292 | 293 | } |
293 | | - actionToProcess && |
294 | | - !afterUserAction && |
295 | | - this.processUserAction(actionToProcess).then((answer) => { |
296 | | - // call AfterUserAction only if there is a valid answer |
297 | | - if (answer) { |
298 | | - answer.msg || answer.msg === "" |
299 | | - ? this.userAction(action, true, answer.answer, answer.msg, type) |
300 | | - : this.userAction(action, true, answer, "", type); |
301 | | - } |
302 | | - }); |
| 294 | + if (actionToProcess && !afterUserAction) { |
| 295 | + const answer = await this.processUserAction(actionToProcess); |
| 296 | + // call AfterUserAction only if there is a valid answer |
| 297 | + if ((action.label = attemptedEditLabel) && answer !== "1") { |
| 298 | + suppressEditListenerMap.set(this.uri.toString(), true); |
| 299 | + await vscode.commands.executeCommand("workbench.action.files.revert", this.uri); |
| 300 | + } |
| 301 | + if (answer) { |
| 302 | + answer.msg || answer.msg === "" |
| 303 | + ? this.userAction(action, true, answer.answer, answer.msg, type) |
| 304 | + : this.userAction(action, true, answer, "", type); |
| 305 | + } |
| 306 | + } |
303 | 307 | }) |
304 | 308 | .then(() => resolve()) |
305 | 309 | .catch((err) => { |
|
0 commit comments