Skip to content

Commit

Permalink
Merge from vscode 3bd60b2 (microsoft#4712)
Browse files Browse the repository at this point in the history
  • Loading branch information
Anthony Dresser authored Mar 27, 2019
1 parent eac3420 commit 46b7afe
Show file tree
Hide file tree
Showing 36 changed files with 303 additions and 137 deletions.
5 changes: 4 additions & 1 deletion build/azure-pipelines/linux/snap-build-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ steps:
- script: |
set -e
# Get snapcraft version
snapcraft --version
# Make sure we get latest packages
sudo apt-get update
sudo apt-get upgrade -y
Expand All @@ -38,7 +41,7 @@ steps:
PACKAGEJSON="$(ls $SNAP_ROOT/code*/usr/share/code*/resources/app/package.json)"
VERSION=$(node -p "require(\"$PACKAGEJSON\").version")
SNAP_PATH="$SNAP_ROOT/$SNAP_FILENAME"
(cd $SNAP_ROOT/code-* && snapcraft snap --output "$SNAP_PATH")
(cd $SNAP_ROOT/code-* && sudo snapcraft snap --output "$SNAP_PATH")
# Publish snap package
AZURE_DOCUMENTDB_MASTERKEY="$(AZURE_DOCUMENTDB_MASTERKEY)" \
Expand Down
10 changes: 8 additions & 2 deletions build/gulpfile.vscode.linux.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,11 +203,17 @@ function prepareSnapPackage(arch) {

return function () {
const desktop = gulp.src('resources/linux/code.desktop', { base: '.' })
.pipe(rename(`usr/share/applications/${product.applicationName}.desktop`));

const desktopUrlHandler = gulp.src('resources/linux/code-url-handler.desktop', { base: '.' })
.pipe(rename(`usr/share/applications/${product.applicationName}-url-handler.desktop`));

const desktops = es.merge(desktop, desktopUrlHandler)
.pipe(replace('@@NAME_LONG@@', product.nameLong))
.pipe(replace('@@NAME_SHORT@@', product.nameShort))
.pipe(replace('@@NAME@@', product.applicationName))
.pipe(replace('@@ICON@@', `/usr/share/pixmaps/${product.linuxIconName}.png`))
.pipe(rename(`usr/share/applications/${product.applicationName}.desktop`));
.pipe(replace('@@URLPROTOCOL@@', product.urlProtocol));

const icon = gulp.src('resources/linux/code.png', { base: '.' })
.pipe(rename(`usr/share/pixmaps/${product.linuxIconName}.png`));
Expand All @@ -223,7 +229,7 @@ function prepareSnapPackage(arch) {
const electronLaunch = gulp.src('resources/linux/snap/electron-launch', { base: '.' })
.pipe(rename('electron-launch'));

const all = es.merge(desktop, icon, code, snapcraft, electronLaunch);
const all = es.merge(desktops, icon, code, snapcraft, electronLaunch);

return all.pipe(vfs.dest(destination));
};
Expand Down
1 change: 1 addition & 0 deletions src/vs/platform/dialogs/common/dialogs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export interface IPickAndOpenOptions {
forceNewWindow?: boolean;
defaultUri?: URI;
telemetryExtraData?: ITelemetryData;
availableFileSystems?: string[];
}

export interface ISaveDialogOptions {
Expand Down
17 changes: 9 additions & 8 deletions src/vs/platform/files/common/files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,30 +285,31 @@ export enum FileSystemProviderErrorCode {
FileNotADirectory = 'EntryNotADirectory',
FileIsADirectory = 'EntryIsADirectory',
NoPermissions = 'NoPermissions',
Unavailable = 'Unavailable'
Unavailable = 'Unavailable',
Unknown = 'Unknown'
}

export class FileSystemProviderError extends Error {

constructor(message: string, public readonly code?: FileSystemProviderErrorCode) {
constructor(message: string, public readonly code: FileSystemProviderErrorCode) {
super(message);
}
}

export function createFileSystemProviderError(error: Error, code?: FileSystemProviderErrorCode): FileSystemProviderError {
export function createFileSystemProviderError(error: Error, code: FileSystemProviderErrorCode): FileSystemProviderError {
const providerError = new FileSystemProviderError(error.toString(), code);
markAsFileSystemProviderError(providerError);
markAsFileSystemProviderError(providerError, code);

return providerError;
}

export function markAsFileSystemProviderError(error: Error, code?: FileSystemProviderErrorCode): Error {
export function markAsFileSystemProviderError(error: Error, code: FileSystemProviderErrorCode): Error {
error.name = code ? `${code} (FileSystemError)` : `FileSystemError`;

return error;
}

export function toFileSystemProviderErrorCode(error: Error): FileSystemProviderErrorCode | undefined {
export function toFileSystemProviderErrorCode(error: Error): FileSystemProviderErrorCode {

// FileSystemProviderError comes with the code
if (error instanceof FileSystemProviderError) {
Expand All @@ -319,7 +320,7 @@ export function toFileSystemProviderErrorCode(error: Error): FileSystemProviderE
// went through the markAsFileSystemProviderError() method
const match = /^(.+) \(FileSystemError\)$/.exec(error.name);
if (!match) {
return undefined;
return FileSystemProviderErrorCode.Unknown;
}

switch (match[1]) {
Expand All @@ -331,7 +332,7 @@ export function toFileSystemProviderErrorCode(error: Error): FileSystemProviderE
case FileSystemProviderErrorCode.Unavailable: return FileSystemProviderErrorCode.Unavailable;
}

return undefined;
return FileSystemProviderErrorCode.Unknown;
}

export function toFileOperationResult(error: Error): FileOperationResult {
Expand Down
5 changes: 3 additions & 2 deletions src/vs/vscode.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6599,10 +6599,11 @@ declare module 'vscode' {
*
* @param name Optional human-readable string which will be used to represent the terminal in the UI.
* @param shellPath Optional path to a custom shell executable to be used in the terminal.
* @param shellArgs Optional args for the custom shell executable, this does not work on Windows (see #8429)
* @param shellArgs Optional args for the custom shell executable. A string can be used on Windows only which
* allows specifying shell args in [command-line format](https://msdn.microsoft.com/en-au/08dfcab2-eb6e-49a4-80eb-87d4076c98c6).
* @return A new Terminal.
*/
export function createTerminal(name?: string, shellPath?: string, shellArgs?: string[]): Terminal;
export function createTerminal(name?: string, shellPath?: string, shellArgs?: string[] | string): Terminal;

/**
* Creates a [Terminal](#Terminal). The cwd of the terminal will be the workspace directory
Expand Down
3 changes: 3 additions & 0 deletions src/vs/workbench/api/common/configurationExtensionPoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,9 @@ jsonRegistry.registerSchema('vscode://schemas/workspaceConfig', {
default: {},
description: nls.localize('workspaceConfig.extensions.description', "Workspace extensions"),
$ref: 'vscode://schemas/extensions'
},
'remoteAuthority': {
type: 'string'
}
},
additionalProperties: false,
Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/api/node/extHost.api.impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ export function createApiFactory(
createWebviewPanel(viewType: string, title: string, showOptions: vscode.ViewColumn | { viewColumn: vscode.ViewColumn, preserveFocus?: boolean }, options: vscode.WebviewPanelOptions & vscode.WebviewOptions): vscode.WebviewPanel {
return extHostWebviews.createWebviewPanel(extension, viewType, title, showOptions, options);
},
createTerminal(nameOrOptions?: vscode.TerminalOptions | string, shellPath?: string, shellArgs?: string[]): vscode.Terminal {
createTerminal(nameOrOptions?: vscode.TerminalOptions | string, shellPath?: string, shellArgs?: string[] | string): vscode.Terminal {
if (typeof nameOrOptions === 'object') {
return extHostTerminalService.createTerminalFromOptions(<vscode.TerminalOptions>nameOrOptions);
}
Expand Down
4 changes: 2 additions & 2 deletions src/vs/workbench/api/node/extHostCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ export class ExtHostCommands implements ExtHostCommandsShape {
try {
validateConstraint(args[i], description.args[i].constraint);
} catch (err) {
return Promise.reject(new Error(`Running the contributed command:'${id}' failed. Illegal argument '${description.args[i].name}' - ${description.args[i].description}`));
return Promise.reject(new Error(`Running the contributed command: '${id}' failed. Illegal argument '${description.args[i].name}' - ${description.args[i].description}`));
}
}
}
Expand All @@ -158,7 +158,7 @@ export class ExtHostCommands implements ExtHostCommandsShape {
return Promise.resolve(result);
} catch (err) {
this._logService.error(err, id);
return Promise.reject(new Error(`Running the contributed command:'${id}' failed.`));
return Promise.reject(new Error(`Running the contributed command: '${id}' failed.`));
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/api/node/extHostComments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ function convertToModeComment(commentController: ExtHostCommentController, vscod
isDraft: vscodeComment.isDraft,
selectCommand: vscodeComment.selectCommand ? commandsConverter.toInternal(vscodeComment.selectCommand) : undefined,
editCommand: vscodeComment.editCommand ? commandsConverter.toInternal(vscodeComment.editCommand) : undefined,
deleteCommand: vscodeComment.editCommand ? commandsConverter.toInternal(vscodeComment.deleteCommand) : undefined,
deleteCommand: vscodeComment.deleteCommand ? commandsConverter.toInternal(vscodeComment.deleteCommand) : undefined,
label: vscodeComment.label,
commentReactions: vscodeComment.commentReactions ? vscodeComment.commentReactions.map(reaction => convertToReaction2(commentController.reactionProvider, reaction)) : undefined
};
Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/api/node/extHostTerminalService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ export class ExtHostTerminalService implements ExtHostTerminalServiceShape {
this._proxy = mainContext.getProxy(MainContext.MainThreadTerminalService);
}

public createTerminal(name?: string, shellPath?: string, shellArgs?: string[]): vscode.Terminal {
public createTerminal(name?: string, shellPath?: string, shellArgs?: string[] | string): vscode.Terminal {
const terminal = new ExtHostTerminal(this._proxy, name);
terminal.create(shellPath, shellArgs);
this._terminals.push(terminal);
Expand Down
4 changes: 2 additions & 2 deletions src/vs/workbench/api/node/extHostTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2207,12 +2207,12 @@ export class FileSystemError extends Error {
return new FileSystemError(messageOrUri, FileSystemProviderErrorCode.Unavailable, FileSystemError.Unavailable);
}

constructor(uriOrMessage?: string | URI, code?: string, terminator?: Function) {
constructor(uriOrMessage?: string | URI, code: FileSystemProviderErrorCode = FileSystemProviderErrorCode.Unknown, terminator?: Function) {
super(URI.isUri(uriOrMessage) ? uriOrMessage.toString(true) : uriOrMessage);

// mark the error as file system provider error so that
// we can extract the error code on the receiving side
markAsFileSystemProviderError(this);
markAsFileSystemProviderError(this, code);

// workaround when extending builtin objects and when compiling to ES5, see:
// https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work
Expand Down
56 changes: 56 additions & 0 deletions src/vs/workbench/browser/actions/workspaceActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { ICommandService } from 'vs/platform/commands/common/commands';
import { ADD_ROOT_FOLDER_COMMAND_ID, ADD_ROOT_FOLDER_LABEL, PICK_WORKSPACE_FOLDER_COMMAND_ID } from 'vs/workbench/browser/actions/workspaceCommands';
import { IFileDialogService } from 'vs/platform/dialogs/common/dialogs';
import { INotificationService } from 'vs/platform/notification/common/notification';
import { Schemas } from 'vs/base/common/network';

export class OpenFileAction extends Action {

Expand All @@ -34,6 +35,24 @@ export class OpenFileAction extends Action {
}
}

export class OpenLocalFileAction extends Action {

static readonly ID = 'workbench.action.files.openLocalFile';
static LABEL = nls.localize('openLocalFile', "Open Local File...");

constructor(
id: string,
label: string,
@IFileDialogService private readonly dialogService: IFileDialogService
) {
super(id, label);
}

run(event?: any, data?: ITelemetryData): Promise<any> {
return this.dialogService.pickFileAndOpen({ forceNewWindow: false, telemetryExtraData: data, availableFileSystems: [Schemas.file] });
}
}

export class OpenFolderAction extends Action {

static readonly ID = 'workbench.action.files.openFolder';
Expand All @@ -52,6 +71,25 @@ export class OpenFolderAction extends Action {
}
}

export class OpenLocalFolderAction extends Action {

static readonly ID = 'workbench.action.files.openLocalFolder';
static LABEL = nls.localize('openLocalFolder', "Open Local Folder...");

constructor(
id: string,
label: string,
@IFileDialogService private readonly dialogService: IFileDialogService
) {
super(id, label);
}

run(event?: any, data?: ITelemetryData): Promise<any> {
return this.dialogService.pickFolderAndOpen({ forceNewWindow: false, telemetryExtraData: data, availableFileSystems: [Schemas.file] });
}
}


export class OpenFileFolderAction extends Action {

static readonly ID = 'workbench.action.files.openFileFolder';
Expand All @@ -70,6 +108,24 @@ export class OpenFileFolderAction extends Action {
}
}

export class OpenLocalFileFolderAction extends Action {

static readonly ID = 'workbench.action.files.openLocalFileFolder';
static LABEL = nls.localize('openLocalFileFolder', "Open Local...");

constructor(
id: string,
label: string,
@IFileDialogService private readonly dialogService: IFileDialogService
) {
super(id, label);
}

run(event?: any, data?: ITelemetryData): Promise<any> {
return this.dialogService.pickFileFolderAndOpen({ forceNewWindow: false, telemetryExtraData: data, availableFileSystems: [Schemas.file] });
}
}

export class AddRootFolderAction extends Action {

static readonly ID = 'workbench.action.addRootFolder';
Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/browser/actions/workspaceCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ CommandsRegistry.registerCommand({
}

// Add and show Files Explorer viewlet
return workspaceEditingService.addFolders(folders.map(folder => ({ uri: folder })))
return workspaceEditingService.addFolders(folders.map(folder => ({ uri: resources.removeTrailingPathSeparator(folder) })))
.then(() => viewletService.openViewlet(viewletService.getDefaultViewletId(), true))
.then(() => undefined);
});
Expand Down
26 changes: 7 additions & 19 deletions src/vs/workbench/browser/dnd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { hasWorkspaceFileExtension, IWorkspacesService } from 'vs/platform/workspaces/common/workspaces';
import { hasWorkspaceFileExtension } from 'vs/platform/workspaces/common/workspaces';
import { normalize } from 'vs/base/common/path';
import { basename } from 'vs/base/common/resources';
import { IFileService } from 'vs/platform/files/common/files';
Expand All @@ -29,6 +29,7 @@ import { Disposable } from 'vs/base/common/lifecycle';
import { addDisposableListener, EventType } from 'vs/base/browser/dom';
import { IEditorGroup } from 'vs/workbench/services/editor/common/editorGroupsService';
import { IRecentFile } from 'vs/platform/history/common/history';
import { IWorkspaceEditingService } from 'vs/workbench/services/workspace/common/workspaceEditing';

export interface IDraggedResource {
resource: URI;
Expand Down Expand Up @@ -154,12 +155,12 @@ export class ResourcesDropHandler {
@IFileService private readonly fileService: IFileService,
@IWindowsService private readonly windowsService: IWindowsService,
@IWindowService private readonly windowService: IWindowService,
@IWorkspacesService private readonly workspacesService: IWorkspacesService,
@ITextFileService private readonly textFileService: ITextFileService,
@IBackupFileService private readonly backupFileService: IBackupFileService,
@IUntitledEditorService private readonly untitledEditorService: IUntitledEditorService,
@IEditorService private readonly editorService: IEditorService,
@IConfigurationService private readonly configurationService: IConfigurationService
@IConfigurationService private readonly configurationService: IConfigurationService,
@IWorkspaceEditingService private readonly workspaceEditingService: IWorkspaceEditingService
) {
}

Expand Down Expand Up @@ -284,26 +285,13 @@ export class ResourcesDropHandler {
// Pass focus to window
this.windowService.focusWindow();

let workspacesToOpen: Promise<IURIToOpen[]> | undefined;

// Open in separate windows if we drop workspaces or just one folder
if (workspaces.length > 0 || folders.length === 1) {
workspacesToOpen = Promise.resolve([...workspaces, ...folders]);
}

// Multiple folders: Create new workspace with folders and open
else if (folders.length > 1) {
workspacesToOpen = this.workspacesService.createUntitledWorkspace(folders).then(workspace => [<IURIToOpen>{ uri: workspace.configPath, typeHint: 'file' }]);
}

// Open
if (workspacesToOpen) {
workspacesToOpen.then(workspaces => {
this.windowService.openWindow(workspaces, { forceReuseWindow: true });
});
return this.windowService.openWindow([...workspaces, ...folders], { forceReuseWindow: true }).then(_ => true);
}

return true;
// folders.length > 1: Multiple folders: Create new workspace with folders and open
return this.workspaceEditingService.createAndEnterWorkspace(folders).then(_ => true);
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/browser/nodeless.simpleservices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1810,7 +1810,7 @@ export class SimpleWorkspacesService implements IWorkspacesService {

_serviceBrand: any;

createUntitledWorkspace(folders?: IWorkspaceFolderCreationData[]): Promise<IWorkspaceIdentifier> {
createUntitledWorkspace(folders?: IWorkspaceFolderCreationData[], remoteAuthority?: string): Promise<IWorkspaceIdentifier> {
// @ts-ignore
return Promise.resolve(undefined);
}
Expand Down
2 changes: 2 additions & 0 deletions src/vs/workbench/common/contextkeys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@ export const IsDevelopmentContext = new RawContextKey<boolean>('isDevelopment',
export const WorkbenchStateContext = new RawContextKey<string>('workbenchState', undefined);

export const WorkspaceFolderCountContext = new RawContextKey<number>('workspaceFolderCount', 0);

export const RemoteFileDialogContext = new RawContextKey<boolean>('remoteFileDialogVisible', false);
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ registerEditorAction(class extends EditorAction {
constructor() {
super({
id: 'editor.showCallHierarchy',
label: localize('title', "Call Hierarchy"),
alias: 'Call Hierarchy',
label: localize('title', "Peek Call Hierarchy"),
alias: 'Peek Call Hierarchy',
menuOpts: {
group: 'navigation',
order: 1.48
Expand Down
Loading

0 comments on commit 46b7afe

Please sign in to comment.