Skip to content

Commit d119d65

Browse files
authored
cli - release --wait if opening fails (fix microsoft#152432) (microsoft#152856)
1 parent 321423d commit d119d65

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

src/vs/workbench/electron-sandbox/window.ts

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { equals } from 'vs/base/common/objects';
1010
import { EventType, EventHelper, addDisposableListener, scheduleAtNextAnimationFrame, ModifierKeyEmitter } from 'vs/base/browser/dom';
1111
import { Separator, WorkbenchActionExecutedClassification, WorkbenchActionExecutedEvent } from 'vs/base/common/actions';
1212
import { IFileService } from 'vs/platform/files/common/files';
13-
import { EditorResourceAccessor, IUntitledTextResourceEditorInput, SideBySideEditor, pathsToEditors, IResourceDiffEditorInput, IUntypedEditorInput } from 'vs/workbench/common/editor';
13+
import { EditorResourceAccessor, IUntitledTextResourceEditorInput, SideBySideEditor, pathsToEditors, IResourceDiffEditorInput, IUntypedEditorInput, IEditorPane } from 'vs/workbench/common/editor';
1414
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
1515
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
1616
import { WindowMinimumSize, IOpenFileRequest, IWindowsConfiguration, getTitleBarStyle, IAddFoldersRequest, INativeRunActionInWindowRequest, INativeRunKeybindingInWindowRequest, INativeOpenFileRequest } from 'vs/platform/window/common/window';
@@ -836,14 +836,23 @@ export class NativeWindow extends Disposable {
836836
}
837837

838838
if (inputs.length) {
839-
this.openResources(inputs, diffMode);
840-
}
839+
const openedEditorPanes = await this.openResources(inputs, diffMode);
840+
841+
if (request.filesToWait) {
842+
843+
// In wait mode, listen to changes to the editors and wait until the files
844+
// are closed that the user wants to wait for. When this happens we delete
845+
// the wait marker file to signal to the outside that editing is done.
846+
// However, it is possible that opening of the editors failed, as such we
847+
// check for whether editor panes got opened and otherwise delete the marker
848+
// right away.
841849

842-
if (request.filesToWait && inputs.length) {
843-
// In wait mode, listen to changes to the editors and wait until the files
844-
// are closed that the user wants to wait for. When this happens we delete
845-
// the wait marker file to signal to the outside that editing is done.
846-
this.trackClosedWaitFiles(URI.revive(request.filesToWait.waitMarkerFileUri), coalesce(request.filesToWait.paths.map(path => URI.revive(path.fileUri))));
850+
if (openedEditorPanes.length) {
851+
return this.trackClosedWaitFiles(URI.revive(request.filesToWait.waitMarkerFileUri), coalesce(request.filesToWait.paths.map(path => URI.revive(path.fileUri))));
852+
} else {
853+
return this.fileService.del(URI.revive(request.filesToWait.waitMarkerFileUri));
854+
}
855+
}
847856
}
848857
}
849858

@@ -856,7 +865,7 @@ export class NativeWindow extends Disposable {
856865
await this.fileService.del(waitMarkerFile);
857866
}
858867

859-
private async openResources(resources: Array<IResourceEditorInput | IUntitledTextResourceEditorInput>, diffMode: boolean): Promise<unknown> {
868+
private async openResources(resources: Array<IResourceEditorInput | IUntitledTextResourceEditorInput>, diffMode: boolean): Promise<readonly IEditorPane[]> {
860869
const editors: IUntypedEditorInput[] = [];
861870

862871
// In diffMode we open 2 resources as diff

0 commit comments

Comments
 (0)