Merge from vscode 0fde6619172c9f04c41f2e816479e432cc974b8b (#5199)

This commit is contained in:
Anthony Dresser
2019-04-24 22:26:02 -07:00
committed by GitHub
parent d63f07d29a
commit 34457880c7
86 changed files with 1254 additions and 702 deletions

View File

@@ -557,8 +557,7 @@ export class CodeWindow extends Disposable implements ICodeWindow {
const configuration = configurationIn ? configurationIn : objects.mixin({}, this.currentConfig);
// Delete some properties we do not want during reload
delete configuration.filesToOpen;
delete configuration.filesToCreate;
delete configuration.filesToOpenOrCreate;
delete configuration.filesToDiff;
delete configuration.filesToWait;

View File

@@ -91,8 +91,7 @@ interface IPathParseOptions {
}
interface IFileInputs {
filesToOpen: IPath[];
filesToCreate: IPath[];
filesToOpenOrCreate: IPath[];
filesToDiff: IPath[];
filesToWait?: IPathsToWaitFor;
remoteAuthority?: string;
@@ -112,9 +111,6 @@ interface IPathToOpen extends IPath {
// the remote authority for the Code instance to open. Undefined if not remote.
remoteAuthority?: string;
// indicator to create the file path in the Code instance
createFilePath?: boolean;
// optional label for the recent history
label?: string;
}
@@ -397,13 +393,9 @@ export class WindowsManager implements IWindowsMainService {
workspacesToOpen.push(path);
} else if (path.fileUri) {
if (!fileInputs) {
fileInputs = { filesToCreate: [], filesToOpen: [], filesToDiff: [], remoteAuthority: path.remoteAuthority };
}
if (!path.createFilePath) {
fileInputs.filesToOpen.push(path);
} else {
fileInputs.filesToCreate.push(path);
fileInputs = { filesToOpenOrCreate: [], filesToDiff: [], remoteAuthority: path.remoteAuthority };
}
fileInputs.filesToOpenOrCreate.push(path);
} else if (path.backupPath) {
emptyToRestore.push({ backupFolder: basename(path.backupPath), remoteAuthority: path.remoteAuthority });
} else {
@@ -413,15 +405,14 @@ export class WindowsManager implements IWindowsMainService {
// When run with --diff, take the files to open as files to diff
// if there are exactly two files provided.
if (fileInputs && openConfig.diffMode && fileInputs.filesToOpen.length === 2) {
fileInputs.filesToDiff = fileInputs.filesToOpen;
fileInputs.filesToOpen = [];
fileInputs.filesToCreate = []; // diff ignores other files that do not exist
if (fileInputs && openConfig.diffMode && fileInputs.filesToOpenOrCreate.length === 2) {
fileInputs.filesToDiff = fileInputs.filesToOpenOrCreate;
fileInputs.filesToOpenOrCreate = [];
}
// When run with --wait, make sure we keep the paths to wait for
if (fileInputs && openConfig.waitMarkerFileURI) {
fileInputs.filesToWait = { paths: [...fileInputs.filesToDiff, ...fileInputs.filesToOpen, ...fileInputs.filesToCreate], waitMarkerFileUri: openConfig.waitMarkerFileURI };
fileInputs.filesToWait = { paths: [...fileInputs.filesToDiff, ...fileInputs.filesToOpenOrCreate], waitMarkerFileUri: openConfig.waitMarkerFileURI };
}
//
@@ -551,7 +542,7 @@ export class WindowsManager implements IWindowsMainService {
if (potentialWindowsCount === 0 && fileInputs) {
// Find suitable window or folder path to open files in
const fileToCheck = fileInputs.filesToOpen[0] || fileInputs.filesToCreate[0] || fileInputs.filesToDiff[0];
const fileToCheck = fileInputs.filesToOpenOrCreate[0] || fileInputs.filesToDiff[0];
// only look at the windows with correct authority
const windows = WindowsManager.WINDOWS.filter(w => w.remoteAuthority === fileInputs!.remoteAuthority);
@@ -746,10 +737,9 @@ export class WindowsManager implements IWindowsMainService {
private doOpenFilesInExistingWindow(configuration: IOpenConfiguration, window: ICodeWindow, fileInputs?: IFileInputs): ICodeWindow {
window.focus(); // make sure window has focus
const params: { filesToOpen?: IPath[], filesToCreate?: IPath[], filesToDiff?: IPath[], filesToWait?: IPathsToWaitFor, termProgram?: string } = {};
const params: { filesToOpenOrCreate?: IPath[], filesToDiff?: IPath[], filesToWait?: IPathsToWaitFor, termProgram?: string } = {};
if (fileInputs) {
params.filesToOpen = fileInputs.filesToOpen;
params.filesToCreate = fileInputs.filesToCreate;
params.filesToOpenOrCreate = fileInputs.filesToOpenOrCreate;
params.filesToDiff = fileInputs.filesToDiff;
params.filesToWait = fileInputs.filesToWait;
}
@@ -958,7 +948,7 @@ export class WindowsManager implements IWindowsMainService {
if (pathToOpen && pathToOpen.folderUri) {
windowsToOpen.push(pathToOpen);
}
} else if (restoreWindows !== 'folders' && openedWindow.backupPath) { // Windows that were Empty
} else if (restoreWindows !== 'folders' && openedWindow.backupPath && !openedWindow.remoteAuthority) { // Local windows that were empty. Empty windows with backups will always be restored in open()
windowsToOpen.push({ backupPath: openedWindow.backupPath, remoteAuthority: openedWindow.remoteAuthority });
}
}
@@ -1065,47 +1055,57 @@ export class WindowsManager implements IWindowsMainService {
anyPath = parsedPath.path;
}
// open remote if either specified in the cli even if it is a local file. TODO: Future idea: resolve in remote host context.
// open remote if either specified in the cli even if it is a local file. TODO@aeschli: Future idea: resolve in remote host context.
const remoteAuthority = options.remoteAuthority;
const candidate = normalize(anyPath);
try {
const candidateStat = fs.statSync(candidate);
if (candidateStat) {
if (candidateStat.isFile()) {
if (candidateStat.isFile()) {
// Workspace (unless disabled via flag)
if (!forceOpenWorkspaceAsFile) {
const workspace = this.workspacesMainService.resolveLocalWorkspaceSync(URI.file(candidate));
if (workspace) {
return { workspace: { id: workspace.id, configPath: workspace.configPath }, remoteAuthority: workspace.remoteAuthority };
}
// Workspace (unless disabled via flag)
if (!forceOpenWorkspaceAsFile) {
const workspace = this.workspacesMainService.resolveLocalWorkspaceSync(URI.file(candidate));
if (workspace) {
return {
workspace: { id: workspace.id, configPath: workspace.configPath },
remoteAuthority: workspace.remoteAuthority,
exists: true
};
}
// File
return {
fileUri: URI.file(candidate),
lineNumber,
columnNumber,
remoteAuthority
};
}
// Folder (we check for isDirectory() because e.g. paths like /dev/null
// are neither file nor folder but some external tools might pass them
// over to us)
else if (candidateStat.isDirectory()) {
return {
folderUri: URI.file(candidate),
remoteAuthority
};
}
// File
return {
fileUri: URI.file(candidate),
lineNumber,
columnNumber,
remoteAuthority,
exists: true
};
}
// Folder (we check for isDirectory() because e.g. paths like /dev/null
// are neither file nor folder but some external tools might pass them
// over to us)
else if (candidateStat.isDirectory()) {
return {
folderUri: URI.file(candidate),
remoteAuthority,
exists: true
};
}
} catch (error) {
const fileUri = URI.file(candidate);
this.historyMainService.removeFromRecentlyOpened([fileUri]); // since file does not seem to exist anymore, remove from recent
// assume this is a file that does not yet exist
if (options && options.ignoreFileNotFound) {
return { fileUri, createFilePath: true, remoteAuthority }; // assume this is a file that does not yet exist
return {
fileUri,
remoteAuthority,
exists: false
};
}
}
@@ -1279,8 +1279,7 @@ export class WindowsManager implements IWindowsMainService {
const fileInputs = options.fileInputs;
if (fileInputs) {
configuration.filesToOpen = fileInputs.filesToOpen;
configuration.filesToCreate = fileInputs.filesToCreate;
configuration.filesToOpenOrCreate = fileInputs.filesToOpenOrCreate;
configuration.filesToDiff = fileInputs.filesToDiff;
configuration.filesToWait = fileInputs.filesToWait;
}