mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-11 10:38:31 -05:00
Merge from vscode 2b0b9136329c181a9e381463a1f7dc3a2d105a34 (#4880)
This commit is contained in:
@@ -7,7 +7,7 @@ import 'vs/css!./media/actions';
|
||||
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { Action } from 'vs/base/common/actions';
|
||||
import { IWindowService, IWindowsService } from 'vs/platform/windows/common/windows';
|
||||
import { IWindowService, IWindowsService, IURIToOpen } from 'vs/platform/windows/common/windows';
|
||||
import * as nls from 'vs/nls';
|
||||
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
|
||||
import { isMacintosh } from 'vs/base/common/platform';
|
||||
@@ -18,7 +18,7 @@ import { FileKind } from 'vs/platform/files/common/files';
|
||||
import { ILabelService } from 'vs/platform/label/common/label';
|
||||
import { IModelService } from 'vs/editor/common/services/modelService';
|
||||
import { IModeService } from 'vs/editor/common/services/modeService';
|
||||
import { IQuickInputService, IQuickPickItem, IQuickInputButton, IQuickPickSeparator, IKeyMods } from 'vs/platform/quickinput/common/quickInput';
|
||||
import { IQuickInputService, IQuickInputButton, IQuickPickSeparator, IKeyMods } from 'vs/platform/quickinput/common/quickInput';
|
||||
import { getIconClasses } from 'vs/editor/common/services/getIconClasses';
|
||||
import product from 'vs/platform/product/node/product';
|
||||
import { ICommandHandler } from 'vs/platform/commands/common/commands';
|
||||
@@ -235,7 +235,7 @@ export abstract class BaseSwitchWindow extends Action {
|
||||
iconClasses: getIconClasses(this.modelService, this.modeService, resource, fileKind),
|
||||
description: (currentWindowId === win.id) ? nls.localize('current', "Current Window") : undefined,
|
||||
buttons: (!this.isQuickNavigate() && currentWindowId !== win.id) ? [this.closeWindowAction] : undefined
|
||||
} as (IQuickPickItem & { payload: number });
|
||||
};
|
||||
});
|
||||
|
||||
const autoFocusIndex = (picks.indexOf(picks.filter(pick => pick.payload === currentWindowId)[0]) + 1) % picks.length;
|
||||
@@ -339,38 +339,36 @@ export abstract class BaseOpenRecentAction extends Action {
|
||||
private openRecent(recentWorkspaces: Array<IRecentWorkspace | IRecentFolder>, recentFiles: IRecentFile[]): void {
|
||||
|
||||
const toPick = (recent: IRecent, labelService: ILabelService, buttons: IQuickInputButton[] | undefined) => {
|
||||
let resource: URI | undefined;
|
||||
let uriToOpen: IURIToOpen | undefined;
|
||||
let iconClasses: string[];
|
||||
let fullLabel: string | undefined;
|
||||
let fileKind: FileKind | undefined;
|
||||
let resource: URI | undefined;
|
||||
if (isRecentFolder(recent)) {
|
||||
resource = recent.folderUri;
|
||||
fullLabel = recent.label || labelService.getWorkspaceLabel(recent.folderUri, { verbose: true });
|
||||
fileKind = FileKind.FOLDER;
|
||||
iconClasses = getIconClasses(this.modelService, this.modeService, resource, FileKind.FOLDER);
|
||||
uriToOpen = { folderUri: resource };
|
||||
fullLabel = recent.label || labelService.getWorkspaceLabel(resource, { verbose: true });
|
||||
} else if (isRecentWorkspace(recent)) {
|
||||
resource = recent.workspace.configPath;
|
||||
iconClasses = getIconClasses(this.modelService, this.modeService, resource, FileKind.ROOT_FOLDER);
|
||||
uriToOpen = { workspaceUri: resource };
|
||||
fullLabel = recent.label || labelService.getWorkspaceLabel(recent.workspace, { verbose: true });
|
||||
fileKind = FileKind.ROOT_FOLDER;
|
||||
} else {
|
||||
resource = recent.fileUri;
|
||||
fullLabel = recent.label || labelService.getUriLabel(recent.fileUri);
|
||||
fileKind = FileKind.FILE;
|
||||
iconClasses = getIconClasses(this.modelService, this.modeService, resource, FileKind.FILE);
|
||||
uriToOpen = { fileUri: resource };
|
||||
fullLabel = recent.label || labelService.getUriLabel(resource);
|
||||
}
|
||||
const { name, parentPath } = splitName(fullLabel);
|
||||
return {
|
||||
iconClasses: getIconClasses(this.modelService, this.modeService, resource, fileKind),
|
||||
iconClasses,
|
||||
label: name,
|
||||
description: parentPath,
|
||||
buttons,
|
||||
resource,
|
||||
fileKind,
|
||||
uriToOpen,
|
||||
resource
|
||||
};
|
||||
};
|
||||
|
||||
const runPick = (uri: URI, isFile: boolean, keyMods: IKeyMods) => {
|
||||
const forceNewWindow = keyMods.ctrlCmd;
|
||||
return this.windowService.openWindow([{ uri, typeHint: isFile ? 'file' : 'folder' }], { forceNewWindow, forceOpenWorkspaceAsFile: isFile });
|
||||
};
|
||||
|
||||
const workspacePicks = recentWorkspaces.map(workspace => toPick(workspace, this.labelService, !this.isQuickNavigate() ? [this.removeFromRecentlyOpened] : undefined));
|
||||
const filePicks = recentFiles.map(p => toPick(p, this.labelService, !this.isQuickNavigate() ? [this.removeFromRecentlyOpened] : undefined));
|
||||
|
||||
@@ -394,7 +392,8 @@ export abstract class BaseOpenRecentAction extends Action {
|
||||
}
|
||||
}).then((pick): Promise<void> | void => {
|
||||
if (pick) {
|
||||
return runPick(pick.resource, pick.fileKind === FileKind.FILE, keyMods);
|
||||
const forceNewWindow = keyMods.ctrlCmd;
|
||||
return this.windowService.openWindow([pick.uriToOpen], { forceNewWindow });
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -13,8 +13,8 @@ import { setZoomLevel, setZoomFactor, setFullscreen } from 'vs/base/browser/brow
|
||||
import { domContentLoaded, addDisposableListener, EventType, scheduleAtNextAnimationFrame } from 'vs/base/browser/dom';
|
||||
import { onUnexpectedError } from 'vs/base/common/errors';
|
||||
import { isLinux, isMacintosh, isWindows } from 'vs/base/common/platform';
|
||||
import { URI as uri } from 'vs/base/common/uri';
|
||||
import { WorkspaceService, DefaultConfigurationExportHelper } from 'vs/workbench/services/configuration/node/configurationService';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { WorkspaceService } from 'vs/workbench/services/configuration/browser/configurationService';
|
||||
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
|
||||
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
|
||||
import { stat } from 'vs/base/node/pfs';
|
||||
@@ -24,13 +24,13 @@ import { IWindowConfiguration, IWindowService } from 'vs/platform/windows/common
|
||||
import { WindowService } from 'vs/platform/windows/electron-browser/windowService';
|
||||
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
|
||||
import { webFrame } from 'electron';
|
||||
import { ISingleFolderWorkspaceIdentifier, IWorkspaceInitializationPayload, IMultiFolderWorkspaceInitializationPayload, IEmptyWorkspaceInitializationPayload, ISingleFolderWorkspaceInitializationPayload, reviveWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces';
|
||||
import { ISingleFolderWorkspaceIdentifier, IWorkspaceInitializationPayload, ISingleFolderWorkspaceInitializationPayload, reviveWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces';
|
||||
import { createSpdLogService } from 'vs/platform/log/node/spdlogService';
|
||||
import { ConsoleLogService, MultiplexLogService, ILogService } from 'vs/platform/log/common/log';
|
||||
import { StorageService } from 'vs/platform/storage/node/storageService';
|
||||
import { LogLevelSetterChannelClient, FollowerLogService } from 'vs/platform/log/node/logIpc';
|
||||
import { Schemas } from 'vs/base/common/network';
|
||||
import { sanitizeFilePath } from 'vs/base/node/extfs';
|
||||
import { sanitizeFilePath } from 'vs/base/common/extpath';
|
||||
import { basename } from 'vs/base/common/path';
|
||||
import { GlobalStorageDatabaseChannelClient } from 'vs/platform/storage/node/storageIpc';
|
||||
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
|
||||
@@ -49,6 +49,9 @@ import { DiskFileSystemProvider } from 'vs/workbench/services/files2/electron-br
|
||||
import { IChannel } from 'vs/base/parts/ipc/common/ipc';
|
||||
import { REMOTE_FILE_SYSTEM_CHANNEL_NAME, RemoteExtensionsFileSystemProvider } from 'vs/platform/remote/common/remoteAgentFileSystemChannel';
|
||||
import { REMOTE_HOST_SCHEME } from 'vs/platform/remote/common/remoteHosts';
|
||||
import { DefaultConfigurationExportHelper } from 'vs/workbench/services/configuration/node/configurationExportHelper';
|
||||
import { ConfigurationCache } from 'vs/workbench/services/configuration/node/configurationCache';
|
||||
import { ConfigurationFileService } from 'vs/workbench/services/configuration/node/configurationFileService';
|
||||
|
||||
class CodeRendererMain extends Disposable {
|
||||
|
||||
@@ -82,8 +85,9 @@ class CodeRendererMain extends Disposable {
|
||||
|
||||
private reviveUris() {
|
||||
if (this.configuration.folderUri) {
|
||||
this.configuration.folderUri = uri.revive(this.configuration.folderUri);
|
||||
this.configuration.folderUri = URI.revive(this.configuration.folderUri);
|
||||
}
|
||||
|
||||
if (this.configuration.workspace) {
|
||||
this.configuration.workspace = reviveWorkspaceIdentifier(this.configuration.workspace);
|
||||
}
|
||||
@@ -94,13 +98,14 @@ class CodeRendererMain extends Disposable {
|
||||
if (Array.isArray(paths)) {
|
||||
paths.forEach(path => {
|
||||
if (path.fileUri) {
|
||||
path.fileUri = uri.revive(path.fileUri);
|
||||
path.fileUri = URI.revive(path.fileUri);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
if (filesToWait) {
|
||||
filesToWait.waitMarkerFileUri = uri.revive(filesToWait.waitMarkerFileUri);
|
||||
filesToWait.waitMarkerFileUri = URI.revive(filesToWait.waitMarkerFileUri);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -182,19 +187,21 @@ class CodeRendererMain extends Disposable {
|
||||
const remoteAuthorityResolverService = new RemoteAuthorityResolverService();
|
||||
serviceCollection.set(IRemoteAuthorityResolverService, remoteAuthorityResolverService);
|
||||
|
||||
const remoteAgentService = new RemoteAgentService(this.configuration, environmentService, remoteAuthorityResolverService);
|
||||
const remoteAgentService = this._register(new RemoteAgentService(this.configuration, environmentService, remoteAuthorityResolverService));
|
||||
serviceCollection.set(IRemoteAgentService, remoteAgentService);
|
||||
|
||||
// Files
|
||||
const fileService = new FileService2(logService);
|
||||
const fileService = this._register(new FileService2(logService));
|
||||
serviceCollection.set(IFileService, fileService);
|
||||
|
||||
fileService.registerProvider(Schemas.file, new DiskFileSystemProvider(logService));
|
||||
const diskFileSystemProvider = this._register(new DiskFileSystemProvider(logService));
|
||||
fileService.registerProvider(Schemas.file, diskFileSystemProvider);
|
||||
|
||||
const connection = remoteAgentService.getConnection();
|
||||
if (connection) {
|
||||
const channel = connection.getChannel<IChannel>(REMOTE_FILE_SYSTEM_CHANNEL_NAME);
|
||||
fileService.registerProvider(REMOTE_HOST_SCHEME, new RemoteExtensionsFileSystemProvider(channel, remoteAgentService.getEnvironment()));
|
||||
const remoteFileSystemProvider = this._register(new RemoteExtensionsFileSystemProvider(channel, remoteAgentService.getEnvironment()));
|
||||
fileService.registerProvider(REMOTE_HOST_SCHEME, remoteFileSystemProvider);
|
||||
}
|
||||
|
||||
return this.resolveWorkspaceInitializationPayload(environmentService).then(payload => Promise.all([
|
||||
@@ -223,7 +230,7 @@ class CodeRendererMain extends Disposable {
|
||||
|
||||
// Multi-root workspace
|
||||
if (this.configuration.workspace) {
|
||||
return Promise.resolve(this.configuration.workspace as IMultiFolderWorkspaceInitializationPayload);
|
||||
return Promise.resolve(this.configuration.workspace);
|
||||
}
|
||||
|
||||
// Single-folder workspace
|
||||
@@ -245,7 +252,7 @@ class CodeRendererMain extends Disposable {
|
||||
return Promise.reject(new Error('Unexpected window configuration without backupPath'));
|
||||
}
|
||||
|
||||
payload = { id } as IEmptyWorkspaceInitializationPayload;
|
||||
payload = { id };
|
||||
}
|
||||
|
||||
return payload;
|
||||
@@ -259,7 +266,7 @@ class CodeRendererMain extends Disposable {
|
||||
return Promise.resolve({ id: createHash('md5').update(folderUri.toString()).digest('hex'), folder: folderUri });
|
||||
}
|
||||
|
||||
function computeLocalDiskFolderId(folder: uri, stat: fs.Stats): string {
|
||||
function computeLocalDiskFolderId(folder: URI, stat: fs.Stats): string {
|
||||
let ctime: number | undefined;
|
||||
if (isLinux) {
|
||||
ctime = stat.ino; // Linux: birthtime is ctime, so we cannot use it! We use the ino instead!
|
||||
@@ -281,16 +288,16 @@ class CodeRendererMain extends Disposable {
|
||||
// For local: ensure path is absolute and exists
|
||||
const sanitizedFolderPath = sanitizeFilePath(folderUri.fsPath, process.env['VSCODE_CWD'] || process.cwd());
|
||||
return stat(sanitizedFolderPath).then(stat => {
|
||||
const sanitizedFolderUri = uri.file(sanitizedFolderPath);
|
||||
const sanitizedFolderUri = URI.file(sanitizedFolderPath);
|
||||
return {
|
||||
id: computeLocalDiskFolderId(sanitizedFolderUri, stat),
|
||||
folder: sanitizedFolderUri
|
||||
} as ISingleFolderWorkspaceInitializationPayload;
|
||||
};
|
||||
}, error => onUnexpectedError(error));
|
||||
}
|
||||
|
||||
private createWorkspaceService(payload: IWorkspaceInitializationPayload, environmentService: IEnvironmentService, remoteAgentService: IRemoteAgentService, logService: ILogService): Promise<WorkspaceService> {
|
||||
const workspaceService = new WorkspaceService(this.configuration, environmentService, remoteAgentService);
|
||||
const workspaceService = new WorkspaceService({ userSettingsResource: URI.file(environmentService.appSettingsPath), remoteAuthority: this.configuration.remoteAuthority, configurationCache: new ConfigurationCache(environmentService) }, new ConfigurationFileService(), remoteAgentService);
|
||||
|
||||
return workspaceService.initialize(payload).then(() => workspaceService, error => {
|
||||
onUnexpectedError(error);
|
||||
|
||||
@@ -115,7 +115,7 @@ export class ElectronWindow extends Disposable {
|
||||
|
||||
// Support runAction event
|
||||
ipc.on('vscode:runAction', (event: Event, request: IRunActionInWindowRequest) => {
|
||||
const args: any[] = request.args || [];
|
||||
const args: unknown[] = request.args || [];
|
||||
|
||||
// If we run an action from the touchbar, we fill in the currently active resource
|
||||
// as payload because the touch bar items are context aware depending on the editor
|
||||
@@ -504,7 +504,7 @@ export class ElectronWindow extends Disposable {
|
||||
}
|
||||
|
||||
private openResources(resources: Array<IResourceInput | IUntitledResourceInput>, diffMode: boolean): void {
|
||||
this.lifecycleService.when(LifecyclePhase.Ready).then((): Promise<any> => {
|
||||
this.lifecycleService.when(LifecyclePhase.Ready).then((): Promise<unknown> => {
|
||||
|
||||
// In diffMode we open 2 resources as diff
|
||||
if (diffMode && resources.length === 2) {
|
||||
@@ -526,9 +526,9 @@ export class ElectronWindow extends Disposable {
|
||||
const resource = URI.revive(p.fileUri);
|
||||
let input: IResourceInput | IUntitledResourceInput;
|
||||
if (isNew) {
|
||||
input = { filePath: resource.fsPath, options: { pinned: true } } as IUntitledResourceInput;
|
||||
input = { filePath: resource.fsPath, options: { pinned: true } };
|
||||
} else {
|
||||
input = { resource, options: { pinned: true } } as IResourceInput;
|
||||
input = { resource, options: { pinned: true } };
|
||||
}
|
||||
|
||||
if (!isNew && typeof p.lineNumber === 'number' && typeof p.columnNumber === 'number') {
|
||||
|
||||
Reference in New Issue
Block a user