提交 619f3201 编写于 作者: M Martin Aeschlimann

waitMarkerFilePath to URI

上级 0f8db6ff
......@@ -422,7 +422,7 @@ export class WindowsManager implements IWindowsMainService {
// When run with --wait, make sure we keep the paths to wait for
if (fileInputs && openConfig.cli.wait && openConfig.cli.waitMarkerFilePath) {
fileInputs.filesToWait = { paths: [...fileInputs.filesToDiff, ...fileInputs.filesToOpen, ...fileInputs.filesToCreate], waitMarkerFilePath: openConfig.cli.waitMarkerFilePath };
fileInputs.filesToWait = { paths: [...fileInputs.filesToDiff, ...fileInputs.filesToOpen, ...fileInputs.filesToCreate], waitMarkerFileUri: URI.file(openConfig.cli.waitMarkerFilePath) };
}
//
......
......@@ -338,11 +338,12 @@ export interface IPath extends IPathData {
export interface IPathsToWaitFor extends IPathsToWaitForData {
paths: IPath[];
waitMarkerFileUri: URI;
}
export interface IPathsToWaitForData {
paths: IPathData[];
waitMarkerFilePath: string;
waitMarkerFileUri: UriComponents;
}
export interface IPathData {
......
......@@ -70,7 +70,7 @@ export abstract class TerminalService implements ITerminalService {
@INotificationService protected readonly _notificationService: INotificationService,
@IDialogService private readonly _dialogService: IDialogService,
@IExtensionService private readonly _extensionService: IExtensionService,
@IFileService private readonly _fileService: IFileService
@IFileService protected readonly _fileService: IFileService
) {
this._activeTabIndex = 0;
this._isShuttingDown = false;
......
......@@ -4,7 +4,6 @@
*--------------------------------------------------------------------------------------------*/
import * as nls from 'vs/nls';
import * as pfs from 'vs/base/node/pfs';
import * as platform from 'vs/base/common/platform';
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
......@@ -27,6 +26,7 @@ import { coalesce } from 'vs/base/common/arrays';
import { IFileService } from 'vs/platform/files/common/files';
import { escapeNonWindowsPath } from 'vs/workbench/contrib/terminal/common/terminalEnvironment';
import { execFile } from 'child_process';
import { URI } from 'vs/base/common/uri';
export class TerminalService extends BrowserTerminalService implements ITerminalService {
public get configHelper(): ITerminalConfigHelper { return this._configHelper; }
......@@ -54,7 +54,8 @@ export class TerminalService extends BrowserTerminalService implements ITerminal
// the termProgram variable) and we are instructed to wait for editors close, wait for the
// marker file to get deleted and then focus back to the integrated terminal.
if (request.termProgram === 'vscode' && request.filesToWait) {
pfs.whenDeleted(request.filesToWait.waitMarkerFilePath).then(() => {
const waitMarkerFileUri = URI.revive(request.filesToWait.waitMarkerFileUri);
this.whenDeleted(waitMarkerFileUri).then(() => {
if (this.terminalInstances.length > 0) {
const terminal = this.getActiveInstance();
if (terminal) {
......@@ -73,6 +74,27 @@ export class TerminalService extends BrowserTerminalService implements ITerminal
});
}
private whenDeleted(path: URI): Promise<void> {
// Complete when wait marker file is deleted
return new Promise<void>(resolve => {
let running = false;
const interval = setInterval(() => {
if (!running) {
running = true;
this._fileService.existsFile(path).then(exists => {
running = false;
if (!exists) {
clearInterval(interval);
resolve(undefined);
}
});
}
}, 1000);
});
}
protected _getDefaultShell(p: platform.Platform): string {
return getDefaultShell(p);
}
......
......@@ -78,7 +78,8 @@ class CodeRendererMain extends Disposable {
this.configuration.workspace = reviveWorkspaceIdentifier(this.configuration.workspace);
}
const filesToWaitPaths = this.configuration.filesToWait && this.configuration.filesToWait.paths;
const filesToWait = this.configuration.filesToWait;
const filesToWaitPaths = filesToWait && filesToWait.paths;
[filesToWaitPaths, this.configuration.filesToOpen, this.configuration.filesToCreate, this.configuration.filesToDiff].forEach(paths => {
if (Array.isArray(paths)) {
paths.forEach(path => {
......@@ -88,6 +89,9 @@ class CodeRendererMain extends Disposable {
});
}
});
if (filesToWait) {
filesToWait.waitMarkerFileUri = uri.revive(filesToWait.waitMarkerFileUri);
}
}
open(): Promise<void> {
......
......@@ -229,7 +229,7 @@ export class ElectronWindow extends Disposable {
const filesToWait = this.windowService.getConfiguration().filesToWait;
if (filesToWait) {
const resourcesToWaitFor = coalesce(filesToWait.paths.map(p => p.fileUri));
const waitMarkerFile = URI.file(filesToWait.waitMarkerFilePath);
const waitMarkerFile = filesToWait.waitMarkerFileUri;
const listenerDispose = this.editorService.onDidCloseEditor(() => this.onEditorClosed(listenerDispose, resourcesToWaitFor, waitMarkerFile));
this._register(listenerDispose);
......@@ -493,7 +493,7 @@ export class ElectronWindow extends Disposable {
// are closed that the user wants to wait for. When this happens we delete
// the wait marker file to signal to the outside that editing is done.
const resourcesToWaitFor = request.filesToWait.paths.map(p => URI.revive(p.fileUri));
const waitMarkerFile = URI.file(request.filesToWait.waitMarkerFilePath);
const waitMarkerFile = URI.revive(request.filesToWait.waitMarkerFileUri);
const unbind = this.editorService.onDidCloseEditor(() => {
if (resourcesToWaitFor.every(resource => !this.editorService.isOpen({ resource }))) {
unbind.dispose();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册