Merge from vscode 31e03b8ffbb218a87e3941f2b63a249f061fe0e4 (#4986)

This commit is contained in:
Anthony Dresser
2019-04-10 16:29:23 -07:00
committed by GitHub
parent 18c54f41bd
commit 8315dacda4
320 changed files with 5540 additions and 3822 deletions

View File

@@ -16,6 +16,7 @@ import { ADD_ROOT_FOLDER_COMMAND_ID, ADD_ROOT_FOLDER_LABEL, PICK_WORKSPACE_FOLDE
import { IFileDialogService } from 'vs/platform/dialogs/common/dialogs';
import { INotificationService } from 'vs/platform/notification/common/notification';
import { Schemas } from 'vs/base/common/network';
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
export class OpenFileAction extends Action {
@@ -289,14 +290,15 @@ export class DuplicateWorkspaceInNewWindowAction extends Action {
@IWorkspaceContextService private readonly workspaceContextService: IWorkspaceContextService,
@IWorkspaceEditingService private readonly workspaceEditingService: IWorkspaceEditingService,
@IWindowService private readonly windowService: IWindowService,
@IWorkspacesService private readonly workspacesService: IWorkspacesService
@IWorkspacesService private readonly workspacesService: IWorkspacesService,
@IWorkbenchEnvironmentService private readonly environmentService: IWorkbenchEnvironmentService
) {
super(id, label);
}
run(): Promise<any> {
const folders = this.workspaceContextService.getWorkspace().folders;
const remoteAuthority = this.windowService.getConfiguration().remoteAuthority;
const remoteAuthority = this.environmentService.configuration.remoteAuthority;
return this.workspacesService.createUntitledWorkspace(folders, remoteAuthority).then(newWorkspace => {
return this.workspaceEditingService.copyWorkspaceSettings(newWorkspace).then(() => {

View File

@@ -44,6 +44,12 @@ export abstract class Composite extends Component implements IComposite {
return this._onDidFocus.event;
}
protected fireOnDidFocus(): void {
if (this._onDidFocus) {
this._onDidFocus.fire();
}
}
private _onDidBlur: Emitter<void>;
get onDidBlur(): Event<void> {
if (!this._onDidBlur) {

View File

@@ -7,13 +7,13 @@ import { Event } from 'vs/base/common/event';
import { Disposable } from 'vs/base/common/lifecycle';
import { IContextKeyService, IContextKey } from 'vs/platform/contextkey/common/contextkey';
import { InputFocusedContext } from 'vs/platform/contextkey/common/contextkeys';
import { IWindowService, IWindowsConfiguration } from 'vs/platform/windows/common/windows';
import { IWindowsConfiguration } from 'vs/platform/windows/common/windows';
import { ActiveEditorContext, EditorsVisibleContext, TextCompareEditorVisibleContext, TextCompareEditorActiveContext, ActiveEditorGroupEmptyContext, MultipleEditorGroupsContext, TEXT_DIFF_EDITOR_ID, SplitEditorsVertically, InEditorZenModeContext } from 'vs/workbench/common/editor';
import { IsMacContext, IsLinuxContext, IsWindowsContext, HasMacNativeTabsContext, IsDevelopmentContext, SupportsWorkspacesContext, SupportsOpenFileFolderContext, WorkbenchStateContext, WorkspaceFolderCountContext, IsRemoteContext } from 'vs/workbench/common/contextkeys';
import { IsMacContext, IsLinuxContext, IsWindowsContext, HasMacNativeTabsContext, IsDevelopmentContext, SupportsWorkspacesContext, WorkbenchStateContext, WorkspaceFolderCountContext, RemoteAuthorityContext } from 'vs/workbench/common/contextkeys';
import { trackFocus, addDisposableListener, EventType } from 'vs/base/browser/dom';
import { preferredSideBySideGroupDirection, GroupDirection, IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
import { WorkbenchState, IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
import { SideBarVisibleContext } from 'vs/workbench/common/viewlet';
@@ -43,8 +43,7 @@ export class WorkbenchContextKeysHandler extends Disposable {
@IContextKeyService private contextKeyService: IContextKeyService,
@IWorkspaceContextService private contextService: IWorkspaceContextService,
@IConfigurationService private configurationService: IConfigurationService,
@IEnvironmentService private environmentService: IEnvironmentService,
@IWindowService private windowService: IWindowService,
@IWorkbenchEnvironmentService private environmentService: IWorkbenchEnvironmentService,
@IEditorService private editorService: IEditorService,
@IEditorGroupsService private editorGroupService: IEditorGroupsService,
@IWorkbenchLayoutService private layoutService: IWorkbenchLayoutService,
@@ -88,7 +87,7 @@ export class WorkbenchContextKeysHandler extends Disposable {
IsLinuxContext.bindTo(this.contextKeyService);
IsWindowsContext.bindTo(this.contextKeyService);
IsRemoteContext.bindTo(this.contextKeyService).set(!!this.windowService.getConfiguration().remoteAuthority);
RemoteAuthorityContext.bindTo(this.contextKeyService).set(this.environmentService.configuration.remoteAuthority || '');
// macOS Native Tabs
const windowConfig = this.configurationService.getValue<IWindowsConfiguration>();
@@ -99,7 +98,6 @@ export class WorkbenchContextKeysHandler extends Disposable {
// File Pickers
SupportsWorkspacesContext.bindTo(this.contextKeyService);
SupportsOpenFileFolderContext.bindTo(this.contextKeyService).set(!!this.windowService.getConfiguration().remoteAuthority);
// Editors
this.activeEditorContext = ActiveEditorContext.bindTo(this.contextKeyService);

View File

@@ -16,7 +16,7 @@ import { IModelService } from 'vs/editor/common/services/modelService';
import { IUntitledEditorService } from 'vs/workbench/services/untitled/common/untitledEditorService';
import { IDecorationsService, IResourceDecorationChangeEvent, IDecorationData } from 'vs/workbench/services/decorations/browser/decorations';
import { Schemas } from 'vs/base/common/network';
import { FileKind, FILES_ASSOCIATIONS_CONFIG } from 'vs/platform/files/common/files';
import { FileKind, FILES_ASSOCIATIONS_CONFIG, IFileService } from 'vs/platform/files/common/files';
import { ITextModel } from 'vs/editor/common/model';
import { IThemeService } from 'vs/platform/theme/common/themeService';
import { Event, Emitter } from 'vs/base/common/event';
@@ -93,7 +93,8 @@ export class ResourceLabels extends Disposable {
@IConfigurationService private readonly configurationService: IConfigurationService,
@IModelService private readonly modelService: IModelService,
@IDecorationsService private readonly decorationsService: IDecorationsService,
@IThemeService private readonly themeService: IThemeService
@IThemeService private readonly themeService: IThemeService,
@IFileService private readonly fileService: IFileService
) {
super();
@@ -116,7 +117,7 @@ export class ResourceLabels extends Disposable {
return; // we need the resource to compare
}
if (e.model.uri.scheme === Schemas.file && e.oldModeId === PLAINTEXT_MODE_ID) { // todo@remote does this apply?
if (this.fileService.canHandleResource(e.model.uri) && e.oldModeId === PLAINTEXT_MODE_ID) {
return; // ignore transitions in files from no mode to specific mode because this happens each time a model is created
}
@@ -202,9 +203,9 @@ export class ResourceLabel extends ResourceLabels {
@IModelService modelService: IModelService,
@IDecorationsService decorationsService: IDecorationsService,
@IThemeService themeService: IThemeService,
@ILabelService labelService: ILabelService
@IFileService fileService: IFileService
) {
super(DEFAULT_LABELS_CONTAINER, instantiationService, extensionService, configurationService, modelService, decorationsService, themeService);
super(DEFAULT_LABELS_CONTAINER, instantiationService, extensionService, configurationService, modelService, decorationsService, themeService, fileService);
this._label = this._register(this.create(container, options));
}

View File

@@ -25,7 +25,7 @@ import { ITitleService } from 'vs/workbench/services/title/common/titleService';
import { IInstantiationService, ServicesAccessor, ServiceIdentifier } from 'vs/platform/instantiation/common/instantiation';
import { LifecyclePhase, StartupKind, ILifecycleService } from 'vs/platform/lifecycle/common/lifecycle';
import { IWindowService, IPath, MenuBarVisibility, getTitleBarStyle } from 'vs/platform/windows/common/windows';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
import { IEditorService, IResourceEditor } from 'vs/workbench/services/editor/common/editorService';
import { IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService';
import { Sizing, Direction, Grid, View } from 'vs/base/browser/ui/grid/grid';
@@ -89,7 +89,7 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
private editorPartView: View;
private statusBarPartView: View;
private environmentService: IEnvironmentService;
private environmentService: IWorkbenchEnvironmentService;
private configurationService: IConfigurationService;
private lifecycleService: ILifecycleService;
private storageService: IStorageService;
@@ -161,12 +161,13 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
protected initLayout(accessor: ServicesAccessor): void {
// Services
this.environmentService = accessor.get(IEnvironmentService);
this.environmentService = accessor.get(IWorkbenchEnvironmentService);
this.configurationService = accessor.get(IConfigurationService);
this.lifecycleService = accessor.get(ILifecycleService);
this.windowService = accessor.get(IWindowService);
this.contextService = accessor.get(IWorkspaceContextService);
this.storageService = accessor.get(IStorageService);
this.backupFileService = accessor.get(IBackupFileService);
// Parts
this.editorService = accessor.get(IEditorService);
@@ -389,7 +390,7 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
}
private resolveEditorsToOpen(): Promise<IResourceEditor[]> | IResourceEditor[] {
const configuration = this.windowService.getConfiguration();
const configuration = this.environmentService.configuration;
const hasInitialFilesToOpen = this.hasInitialFilesToOpen();
// Only restore editors if we are not instructed to open files initially
@@ -418,8 +419,7 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
// Empty workbench
else if (this.contextService.getWorkbenchState() === WorkbenchState.EMPTY && this.configurationService.inspect('workbench.startupEditor').value === 'newUntitledFile') {
const isEmpty = this.editorGroupService.count === 1 && this.editorGroupService.activeGroup.count === 0;
if (!isEmpty) {
if (this.editorGroupService.willRestoreEditors) {
return []; // do not open any empty untitled file if we restored editors from previous session
}
@@ -436,7 +436,7 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
}
private hasInitialFilesToOpen(): boolean {
const configuration = this.windowService.getConfiguration();
const configuration = this.environmentService.configuration;
return !!(
(configuration.filesToCreate && configuration.filesToCreate.length > 0) ||

View File

@@ -8,8 +8,18 @@ import { domContentLoaded, addDisposableListener, EventType } from 'vs/base/brow
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
import { ILogService } from 'vs/platform/log/common/log';
import { Disposable } from 'vs/base/common/lifecycle';
import { SimpleLogService } from 'vs/workbench/browser/nodeless.simpleservices';
import { SimpleLogService, SimpleProductService, SimpleWorkbenchEnvironmentService } from 'vs/workbench/browser/nodeless.simpleservices';
import { Workbench } from 'vs/workbench/browser/workbench';
import { IChannel } from 'vs/base/parts/ipc/common/ipc';
import { REMOTE_FILE_SYSTEM_CHANNEL_NAME, RemoteExtensionsFileSystemProvider } from 'vs/platform/remote/common/remoteAgentFileSystemChannel';
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
import { IProductService } from 'vs/platform/product/common/product';
import { RemoteAgentService } from 'vs/workbench/services/remote/browser/remoteAgentServiceImpl';
import { RemoteAuthorityResolverService } from 'vs/platform/remote/browser/remoteAuthorityResolverService';
import { IRemoteAuthorityResolverService } from 'vs/platform/remote/common/remoteAuthorityResolver';
import { IRemoteAgentService } from 'vs/workbench/services/remote/common/remoteAgentService';
import { IFileService } from 'vs/platform/files/common/files';
import { FileService3 } from 'vs/workbench/services/files2/browser/fileService2';
class CodeRendererMain extends Disposable {
@@ -42,14 +52,41 @@ class CodeRendererMain extends Disposable {
private initServices(): { serviceCollection: ServiceCollection, logService: ILogService } {
const serviceCollection = new ServiceCollection();
const logService = new SimpleLogService();
serviceCollection.set(ILogService, logService);
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// NOTE: DO NOT ADD ANY OTHER SERVICE INTO THE COLLECTION HERE.
// CONTRIBUTE IT VIA WORKBENCH.MAIN.TS AND registerSingleton().
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// Log
const logService = new SimpleLogService();
serviceCollection.set(ILogService, logService);
// Environment
const environmentService = new SimpleWorkbenchEnvironmentService();
serviceCollection.set(IWorkbenchEnvironmentService, environmentService);
// Product
const productService = new SimpleProductService();
serviceCollection.set(IProductService, productService);
// Remote
const remoteAuthorityResolverService = new RemoteAuthorityResolverService();
serviceCollection.set(IRemoteAuthorityResolverService, remoteAuthorityResolverService);
const remoteAgentService = this._register(new RemoteAgentService(environmentService, productService, remoteAuthorityResolverService));
serviceCollection.set(IRemoteAgentService, remoteAgentService);
// Files
const fileService = this._register(new FileService3(logService));
serviceCollection.set(IFileService, fileService);
const connection = remoteAgentService.getConnection();
if (connection) {
const channel = connection.getChannel<IChannel>(REMOTE_FILE_SYSTEM_CHANNEL_NAME);
const remoteFileSystemProvider = this._register(new RemoteExtensionsFileSystemProvider(channel, remoteAgentService.getEnvironment()));
fileService.registerProvider('vscode-remote', remoteFileSystemProvider);
}
return { serviceCollection, logService };
}
}

View File

@@ -5,7 +5,7 @@
import { URI } from 'vs/base/common/uri';
import { IBackupFileService } from 'vs/workbench/services/backup/common/backup';
import { ITextSnapshot, IFileStat, IContent, IFileService, IResourceEncodings, IResolveFileOptions, IResolveFileResult, IResolveContentOptions, IStreamContent, IUpdateContentOptions, snapshotToString, ICreateFileOptions, IResourceEncoding, IFileStatWithMetadata, FileSystemProviderCapabilities } from 'vs/platform/files/common/files';
import { ITextSnapshot } from 'vs/platform/files/common/files';
import { ITextBufferFactory } from 'vs/editor/common/model';
import { createTextBufferFactoryFromSnapshot } from 'vs/editor/common/model/textModel';
import { keys, ResourceMap } from 'vs/base/common/map';
@@ -17,7 +17,7 @@ import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService
import { SimpleConfigurationService as StandaloneEditorConfigurationService, StandaloneKeybindingService, SimpleResourcePropertiesService } from 'vs/editor/standalone/browser/simpleServices';
import { IDownloadService } from 'vs/platform/download/common/download';
import { CancellationToken } from 'vs/base/common/cancellation';
import { IEnvironmentService, IExtensionHostDebugParams, IDebugParams } from 'vs/platform/environment/common/environment';
import { IExtensionHostDebugParams, IDebugParams } from 'vs/platform/environment/common/environment';
import { IExtensionGalleryService, IQueryOptions, IGalleryExtension, InstallOperation, StatisticType, ITranslation, IGalleryExtensionVersion, IExtensionIdentifier, IReportedExtension, IExtensionManagementService, ILocalExtension, IGalleryMetadata, IExtensionTipsService, ExtensionRecommendationReason, IExtensionRecommendation, IExtensionEnablementService, EnablementState } from 'vs/platform/extensionManagement/common/extensionManagement';
import { IPager } from 'vs/base/common/paging';
import { IExtensionManifest, ExtensionType, ExtensionIdentifier, IExtension } from 'vs/platform/extensions/common/extensions';
@@ -32,9 +32,7 @@ import { ILogService, LogLevel, ConsoleLogService } from 'vs/platform/log/common
import { ShutdownReason, ILifecycleService } from 'vs/platform/lifecycle/common/lifecycle';
import { IMenubarService, IMenubarData } from 'vs/platform/menubar/common/menubar';
import { IProductService } from 'vs/platform/product/common/product';
import { IRemoteAuthorityResolverService, ResolvedAuthority } from 'vs/platform/remote/common/remoteAuthorityResolver';
import { joinPath, isEqualOrParent, isEqual, dirname } from 'vs/base/common/resources';
import { basename } from 'vs/base/common/path';
import { isEqualOrParent, isEqual } from 'vs/base/common/resources';
import { ISearchService, ITextQueryProps, ISearchProgressItem, ISearchComplete, IFileQueryProps, SearchProviderType, ISearchResultProvider, ITextQuery, IFileMatch, QueryType, FileMatch, pathIncludedInQuery } from 'vs/workbench/services/search/common/search';
import { IModelService } from 'vs/editor/common/services/modelService';
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
@@ -48,7 +46,7 @@ import { ITextMateService, IGrammar as ITextMategrammar } from 'vs/workbench/ser
import { LanguageId, TokenizationRegistry } from 'vs/editor/common/modes';
import { IUpdateService, State } from 'vs/platform/update/common/update';
import { IWindowConfiguration, IPath, IPathsToWaitFor, IWindowService, INativeOpenDialogOptions, IEnterWorkspaceResult, IURIToOpen, IMessageBoxResult, IWindowsService, IOpenSettings } from 'vs/platform/windows/common/windows';
import { IProcessEnvironment, isWindows } from 'vs/base/common/platform';
import { IProcessEnvironment } from 'vs/base/common/platform';
import { IWorkspaceIdentifier, ISingleFolderWorkspaceIdentifier, IWorkspaceFolderCreationData, isSingleFolderWorkspaceIdentifier, IWorkspacesService } from 'vs/platform/workspaces/common/workspaces';
import { ExportData } from 'vs/base/common/performance';
import { IRecentlyOpened, IRecent } from 'vs/platform/history/common/history';
@@ -59,10 +57,14 @@ import { ITextResourcePropertiesService } from 'vs/editor/common/services/resour
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { Color, RGBA } from 'vs/base/common/color';
import { IRemoteAgentEnvironment } from 'vs/platform/remote/common/remoteAgentEnvironment';
import { IRemoteAgentService, IRemoteAgentConnection } from 'vs/workbench/services/remote/common/remoteAgentService';
import { ITunnelService } from 'vs/platform/remote/common/tunnel';
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
export const workspaceResource = URI.file(isWindows ? 'C:\\simpleWorkspace' : '/simpleWorkspace');
export const workspaceResource = URI.from({
scheme: 'vscode-remote',
authority: document.location.host,
path: (<any>self).USER_HOME_DIR || '/'
});
//#region Backup File
@@ -225,7 +227,8 @@ registerSingleton(IDownloadService, SimpleDownloadService, true);
//#region Environment
export class SimpleEnvironmentService implements IEnvironmentService {
export class SimpleWorkbenchEnvironmentService implements IWorkbenchEnvironmentService {
configuration: IWindowConfiguration = new SimpleWindowConfiguration();
untitledWorkspacesHome: URI;
extensionTestsLocationURI?: URI;
_serviceBrand: any;
@@ -240,6 +243,8 @@ export class SimpleEnvironmentService implements IEnvironmentService {
appSettingsHome: string = '/nodeless/settings';
appSettingsPath: string = '/nodeless/settings/settings.json';
appKeybindingsPath: string = '/nodeless/settings/keybindings.json';
machineSettingsHome: string;
machineSettingsPath: string;
settingsSearchBuildId?: number;
settingsSearchUrl?: string;
globalStorageHome: string;
@@ -251,7 +256,7 @@ export class SimpleEnvironmentService implements IEnvironmentService {
disableExtensions: boolean | string[];
builtinExtensionsPath: string;
extensionsPath: string;
extensionDevelopmentLocationURI?: URI | URI[];
extensionDevelopmentLocationURI?: URI[];
extensionTestsPath?: string;
debugExtensionHost: IExtensionHostDebugParams;
debugSearch: IDebugParams;
@@ -275,7 +280,6 @@ export class SimpleEnvironmentService implements IEnvironmentService {
driverVerbose: boolean;
}
registerSingleton(IEnvironmentService, SimpleEnvironmentService);
//#endregion
@@ -667,425 +671,6 @@ export class SimpleProductService implements IProductService {
enableTelemetry: boolean = false;
}
registerSingleton(IProductService, SimpleProductService, true);
//#endregion
//#region Remote Agent
export class SimpleRemoteAgentService implements IRemoteAgentService {
_serviceBrand: any;
getConnection(): IRemoteAgentConnection | null {
return null;
}
getEnvironment(): Promise<IRemoteAgentEnvironment | null> {
return Promise.resolve(null);
}
}
registerSingleton(IRemoteAgentService, SimpleRemoteAgentService);
//#endregion
//#region Remote Authority Resolver
export class SimpleRemoteAuthorityResolverService implements IRemoteAuthorityResolverService {
_serviceBrand: any;
resolveAuthority(authority: string): Promise<ResolvedAuthority> {
// @ts-ignore
return Promise.resolve(undefined);
}
clearResolvedAuthority(authority: string): void { }
setResolvedAuthority(resolvedAuthority: ResolvedAuthority): void { }
setResolvedAuthorityError(authority: string, err: any): void { }
}
registerSingleton(IRemoteAuthorityResolverService, SimpleRemoteAuthorityResolverService, true);
//#endregion
//#region File Servie
const fileMap: ResourceMap<IFileStat> = new ResourceMap();
const contentMap: ResourceMap<IContent> = new ResourceMap();
initFakeFileSystem();
export class SimpleRemoteFileService implements IFileService {
_serviceBrand: any;
encoding: IResourceEncodings;
readonly onFileChanges = Event.None;
readonly onAfterOperation = Event.None;
readonly onDidChangeFileSystemProviderRegistrations = Event.None;
readonly onWillActivateFileSystemProvider = Event.None;
readonly onError = Event.None;
resolve(resource: URI, options?: IResolveFileOptions): Promise<IFileStatWithMetadata> {
// @ts-ignore
return Promise.resolve(fileMap.get(resource));
}
resolveAll(toResolve: { resource: URI, options?: IResolveFileOptions }[]): Promise<IResolveFileResult[]> {
return Promise.all(toResolve.map(resourceAndOption => this.resolve(resourceAndOption.resource, resourceAndOption.options))).then(stats => stats.map(stat => ({ stat, success: true })));
}
exists(resource: URI): Promise<boolean> {
return Promise.resolve(fileMap.has(resource));
}
resolveContent(resource: URI, _options?: IResolveContentOptions): Promise<IContent> {
// @ts-ignore
return Promise.resolve(contentMap.get(resource));
}
resolveStreamContent(resource: URI, _options?: IResolveContentOptions): Promise<IStreamContent> {
return Promise.resolve(contentMap.get(resource)).then(content => {
return {
// @ts-ignore
resource: content.resource,
value: {
on: (event: string, callback: Function): void => {
if (event === 'data') {
// @ts-ignore
callback(content.value);
}
if (event === 'end') {
callback();
}
}
},
// @ts-ignore
etag: content.etag,
// @ts-ignore
encoding: content.encoding,
// @ts-ignore
mtime: content.mtime,
// @ts-ignore
name: content.name,
// @ts-ignore
size: content.size
};
});
}
updateContent(resource: URI, value: string | ITextSnapshot, _options?: IUpdateContentOptions): Promise<IFileStatWithMetadata> {
// @ts-ignore
return Promise.resolve(fileMap.get(resource)).then(file => {
const content = contentMap.get(resource);
if (typeof value === 'string') {
// @ts-ignore
content.value = value;
} else {
// @ts-ignore
content.value = snapshotToString(value);
}
return file;
});
}
move(_source: URI, _target: URI, _overwrite?: boolean): Promise<IFileStatWithMetadata> { return Promise.resolve(null!); }
copy(_source: URI, _target: URI, _overwrite?: boolean): Promise<any> {
const parent = fileMap.get(dirname(_target));
if (!parent) {
return Promise.resolve(undefined);
}
return this.resolveContent(_source).then(content => {
return Promise.resolve(createFile(parent, basename(_target.path), content.value));
});
}
createFile(_resource: URI, _content?: string, _options?: ICreateFileOptions): Promise<IFileStatWithMetadata> {
const parent = fileMap.get(dirname(_resource));
if (!parent) {
return Promise.reject(new Error(`Unable to create file in ${dirname(_resource).path}`));
}
return Promise.resolve(createFile(parent, basename(_resource.path)));
}
createFolder(_resource: URI): Promise<IFileStatWithMetadata> {
const parent = fileMap.get(dirname(_resource));
if (!parent) {
return Promise.reject(new Error(`Unable to create folder in ${dirname(_resource).path}`));
}
return Promise.resolve(createFolder(parent, basename(_resource.path)));
}
registerProvider() { return { dispose() { } }; }
activateProvider(_scheme: string): Promise<void> { return Promise.resolve(undefined); }
canHandleResource(resource: URI): boolean { return resource.scheme === 'file'; }
hasCapability(resource: URI, capability: FileSystemProviderCapabilities): boolean { return false; }
del(_resource: URI, _options?: { useTrash?: boolean, recursive?: boolean }): Promise<void> { return Promise.resolve(); }
watch(_resource: URI): IDisposable { return Disposable.None; }
getWriteEncoding(_resource: URI): IResourceEncoding { return { encoding: 'utf8', hasBOM: false }; }
dispose(): void { }
}
function createFile(parent: IFileStat, name: string, content: string = ''): IFileStatWithMetadata {
const file: IFileStatWithMetadata = {
resource: joinPath(parent.resource, name),
etag: Date.now().toString(),
mtime: Date.now(),
isDirectory: false,
name,
size: -1
};
// @ts-ignore
parent.children.push(file);
fileMap.set(file.resource, file);
contentMap.set(file.resource, {
resource: joinPath(parent.resource, name),
etag: Date.now().toString(),
mtime: Date.now(),
value: content,
encoding: 'utf8',
name
} as IContent);
return file;
}
function createFolder(parent: IFileStat, name: string): IFileStatWithMetadata {
const folder: IFileStatWithMetadata = {
resource: joinPath(parent.resource, name),
etag: Date.now().toString(),
mtime: Date.now(),
isDirectory: true,
name,
size: 0,
children: []
};
// @ts-ignore
parent.children.push(folder);
fileMap.set(folder.resource, folder);
return folder;
}
function initFakeFileSystem(): void {
const root: IFileStat = {
resource: workspaceResource,
etag: Date.now().toString(),
mtime: Date.now(),
isDirectory: true,
name: basename(workspaceResource.fsPath),
children: [],
size: 0
};
fileMap.set(root.resource, root);
createFile(root, '.gitignore', `out
node_modules
.vscode-test/
*.vsix
`);
createFile(root, '.vscodeignore', `.vscode/**
.vscode-test/**
out/test/**
src/**
.gitignore
vsc-extension-quickstart.md
**/tsconfig.json
**/tslint.json
**/*.map
**/*.ts`);
createFile(root, 'CHANGELOG.md', `# Change Log
All notable changes to the "test-ts" extension will be documented in this file.
Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file.
## [Unreleased]
- Initial release`);
createFile(root, 'package.json', `{
"name": "test-ts",
"displayName": "test-ts",
"description": "",
"version": "0.0.1",
"engines": {
"vscode": "^1.31.0"
},
"categories": [
"Other"
],
"activationEvents": [
"onCommand:extension.helloWorld"
],
"main": "./out/extension.js",
"contributes": {
"commands": [
{
"command": "extension.helloWorld",
"title": "Hello World"
}
]
},
"scripts": {
"vscode:prepublish": "npm run compile",
"compile": "tsc -p ./",
"watch": "tsc -watch -p ./",
"postinstall": "node ./node_modules/vscode/bin/install",
"test": "npm run compile && node ./node_modules/vscode/bin/test"
},
"devDependencies": {
"typescript": "^3.3.1",
"vscode": "^1.1.28",
"tslint": "^5.12.1",
"@types/node": "^8.10.25",
"@types/mocha": "^2.2.42"
}
}
`);
createFile(root, 'tsconfig.json', `{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"outDir": "out",
"lib": [
"es6"
],
"sourceMap": true,
"rootDir": "src",
"strict": true /* enable all strict type-checking options */
/* Additional Checks */
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
// "noUnusedParameters": true, /* Report errors on unused parameters. */
},
"exclude": [
"node_modules",
".vscode-test"
]
}
`);
createFile(root, 'tslint.json', `{
"rules": {
"no-string-throw": true,
"no-unused-expression": true,
"no-duplicate-variable": true,
"curly": true,
"class-name": true,
"semicolon": [
true,
"always"
],
"triple-equals": true
},
"defaultSeverity": "warning"
}
`);
const src = createFolder(root, 'src');
createFile(src, 'extension.ts', `// The module 'vscode' contains the VS Code extensibility API
// Import the module and reference it with the alias vscode in your code below
import * as vscode from 'vscode';
// this method is called when your extension is activated
// your extension is activated the very first time the command is executed
export function activate(context: vscode.ExtensionContext) {
// Use the console to output diagnostic information (console.log) and errors (console.error)
// This line of code will only be executed once when your extension is activated
console.log('Congratulations, your extension "test-ts" is now active!');
// The command has been defined in the package.json file
// Now provide the implementation of the command with registerCommand
// The commandId parameter must match the command field in package.json
let disposable = vscode.commands.registerCommand('extension.helloWorld', () => {
// The code you place here will be executed every time your command is executed
// Display a message box to the user
vscode.window.showInformationMessage('Hello World!');
});
context.subscriptions.push(disposable);
}
// this method is called when your extension is deactivated
export function deactivate() {}
`);
const test = createFolder(src, 'test');
createFile(test, 'extension.test.ts', `//
// Note: This example test is leveraging the Mocha test framework.
// Please refer to their documentation on https://mochajs.org/ for help.
//
// The module 'assert' provides assertion methods from node
import * as assert from 'assert';
// You can import and use all API from the 'vscode' module
// as well as import your extension to test it
// import * as vscode from 'vscode';
// import * as myExtension from '../extension';
// Defines a Mocha test suite to group tests of similar kind together
suite("Extension Tests", function () {
// Defines a Mocha unit test
test("Something 1", function() {
assert.equal(-1, [1, 2, 3].indexOf(5));
assert.equal(-1, [1, 2, 3].indexOf(0));
});
});`);
createFile(test, 'index.ts', `//
// PLEASE DO NOT MODIFY / DELETE UNLESS YOU KNOW WHAT YOU ARE DOING
//
// This file is providing the test runner to use when running extension tests.
// By default the test runner in use is Mocha based.
//
// You can provide your own test runner if you want to override it by exporting
// a function run(testRoot: string, clb: (error:Error) => void) that the extension
// host can call to run the tests. The test runner is expected to use console.log
// to report the results back to the caller. When the tests are finished, return
// a possible error to the callback or null if none.
import * as testRunner from 'vscode/lib/testrunner';
// You can directly control Mocha options by configuring the test runner below
// See https://github.com/mochajs/mocha/wiki/Using-mocha-programmatically#set-options
// for more info
testRunner.configure({
ui: 'tdd', // the TDD UI is being used in extension.test.ts (suite, test, etc.)
useColors: true // colored output from test results
});
module.exports = testRunner;`);
}
registerSingleton(IFileService, SimpleRemoteFileService);
//#endregion
//#region Request
@@ -1382,7 +967,7 @@ export class SimpleWindowService implements IWindowService {
hasFocus = true;
private configuration: IWindowConfiguration = new SimpleWindowConfiguration();
readonly windowId = 0;
isFocused(): Promise<boolean> {
return Promise.resolve(false);
@@ -1392,14 +977,6 @@ export class SimpleWindowService implements IWindowService {
return Promise.resolve(false);
}
getConfiguration(): IWindowConfiguration {
return this.configuration;
}
getCurrentWindowId(): number {
return 0;
}
pickFileFolderAndOpen(_options: INativeOpenDialogOptions): Promise<void> {
return Promise.resolve();
}
@@ -1788,7 +1365,7 @@ export class SimpleWorkspaceService implements IWorkspaceContextService {
constructor() {
this.workspace = new Workspace(
workspaceResource.toString(),
toWorkspaceFolders([{ path: workspaceResource.fsPath }])
toWorkspaceFolders([{ uri: workspaceResource.toString() }])
);
}
@@ -1861,3 +1438,16 @@ export class SimpleWorkspacesService implements IWorkspacesService {
registerSingleton(IWorkspacesService, SimpleWorkspacesService);
//#endregion
//#region remote
class SimpleTunnelService implements ITunnelService {
_serviceBrand: any;
openTunnel(remotePort: number) {
return undefined;
}
}
registerSingleton(ITunnelService, SimpleTunnelService);
//#endregion

View File

@@ -51,6 +51,8 @@ import { Schemas } from 'vs/base/common/network';
import { registerEditorContribution } from 'vs/editor/browser/editorExtensions';
import { OpenWorkspaceButtonContribution } from 'vs/workbench/browser/parts/editor/editorWidgets';
import { ZoomStatusbarItem } from 'vs/workbench/browser/parts/editor/resourceViewer';
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
import { toLocalResource } from 'vs/base/common/resources';
// Register String Editor
Registry.as<IEditorRegistry>(EditorExtensions.Editors).registerEditor(
@@ -111,7 +113,8 @@ interface ISerializedUntitledEditorInput {
class UntitledEditorInputFactory implements IEditorInputFactory {
constructor(
@ITextFileService private readonly textFileService: ITextFileService
@ITextFileService private readonly textFileService: ITextFileService,
@IWorkbenchEnvironmentService private readonly environmentService: IWorkbenchEnvironmentService
) { }
serialize(editorInput: EditorInput): string | undefined {
@@ -128,7 +131,7 @@ class UntitledEditorInputFactory implements IEditorInputFactory {
let resource = untitledEditorInput.getResource();
if (untitledEditorInput.hasAssociatedFilePath) {
resource = resource.with({ scheme: Schemas.file }); // untitled with associated file path use the file schema
resource = toLocalResource(resource, this.environmentService.configuration.remoteAuthority); // untitled with associated file path use the local schema
}
const serialized: ISerializedUntitledEditorInput = {
@@ -145,7 +148,7 @@ class UntitledEditorInputFactory implements IEditorInputFactory {
return instantiationService.invokeFunction<UntitledEditorInput>(accessor => {
const deserialized: ISerializedUntitledEditorInput = JSON.parse(serializedEditorInput);
const resource = !!deserialized.resourceJSON ? URI.revive(deserialized.resourceJSON) : URI.parse(deserialized.resource);
const filePath = resource.scheme === Schemas.file ? resource.fsPath : undefined;
const filePath = resource.scheme === Schemas.untitled ? undefined : resource.scheme === Schemas.file ? resource.fsPath : resource.path;
const language = deserialized.modeId;
const encoding = deserialized.encoding;

View File

@@ -231,6 +231,10 @@ export class EditorPart extends Part implements IEditorGroupsService, IEditorGro
return this._whenRestored;
}
get willRestoreEditors(): boolean {
return !!this.workspaceMemento[EditorPart.EDITOR_PART_UI_STATE_STORAGE_KEY];
}
getGroups(order = GroupsOrder.CREATION_TIME): IEditorGroupView[] {
switch (order) {
case GroupsOrder.CREATION_TIME:

View File

@@ -4,13 +4,13 @@
*--------------------------------------------------------------------------------------------*/
import { INotificationsModel, INotificationChangeEvent, NotificationChangeType, INotificationViewItem } from 'vs/workbench/common/notifications';
import { IStatusbarService, StatusbarAlignment } from 'vs/platform/statusbar/common/statusbar';
import { IDisposable, Disposable } from 'vs/base/common/lifecycle';
import { IStatusbarService, StatusbarAlignment, IStatusbarEntryAccessor, IStatusbarEntry } from 'vs/platform/statusbar/common/statusbar';
import { Disposable } from 'vs/base/common/lifecycle';
import { HIDE_NOTIFICATIONS_CENTER, SHOW_NOTIFICATIONS_CENTER } from 'vs/workbench/browser/parts/notifications/notificationsCommands';
import { localize } from 'vs/nls';
export class NotificationsStatus extends Disposable {
private statusItem: IDisposable;
private statusItem: IStatusbarEntryAccessor;
private isNotificationsCenterVisible: boolean;
private _counter: Set<INotificationViewItem>;
@@ -64,19 +64,18 @@ export class NotificationsStatus extends Disposable {
}
private updateNotificationsStatusItem(): void {
// Dispose old first
if (this.statusItem) {
this.statusItem.dispose();
}
// Create new
this.statusItem = this.statusbarService.addEntry({
const statusProperties: IStatusbarEntry = {
text: this.count === 0 ? '$(bell)' : `$(bell) ${this.count}`,
command: this.isNotificationsCenterVisible ? HIDE_NOTIFICATIONS_CENTER : SHOW_NOTIFICATIONS_CENTER,
tooltip: this.getTooltip(),
showBeak: this.isNotificationsCenterVisible
}, StatusbarAlignment.RIGHT, -1000 /* towards the far end of the right hand side */);
};
if (!this.statusItem) {
this.statusItem = this.statusbarService.addEntry(statusProperties, StatusbarAlignment.RIGHT, -1000 /* towards the far end of the right hand side */);
} else {
this.statusItem.update(statusProperties);
}
}
private getTooltip(): string {
@@ -98,12 +97,4 @@ export class NotificationsStatus extends Disposable {
return localize('notifications', "{0} New Notifications", this.count);
}
dispose() {
super.dispose();
if (this.statusItem) {
this.statusItem.dispose();
}
}
}

View File

@@ -49,16 +49,27 @@
.monaco-workbench .part.statusbar > .statusbar-item.right + .statusbar-item.left {
padding-left: 7px;
}
.monaco-workbench .part.statusbar > .statusbar-item.has-background-color.left:first-child,
.monaco-workbench .part.statusbar > .statusbar-item.right + .statusbar-item.has-background-color.left {
padding-right: 7px; /* expand padding if background color is configured for the status bar entry to make it look centered properly */
}
/* adding padding to the most right status bar item */
.monaco-workbench .part.statusbar > .statusbar-item.right:first-child {
padding-right: 7px;
}
/* tweak appearance for items with background to improve hover feedback */
.monaco-workbench .part.statusbar > .statusbar-item.has-background-color.left:first-child,
.monaco-workbench .part.statusbar > .statusbar-item.right + .statusbar-item.has-background-color.left,
.monaco-workbench .part.statusbar > .statusbar-item.has-background-color.right:first-child {
padding-left: 7px; /* expand padding if background color is configured for the status bar entry to make it look centered properly */
padding-right: 0;
padding-left: 0;
}
.monaco-workbench .part.statusbar > .statusbar-item.has-background-color.left > :first-child,
.monaco-workbench .part.statusbar > .statusbar-item.has-background-color.right > :first-child
{
margin-right: 0;
margin-left: 0;
padding-left: 10px;
padding-right: 10px;
}
.monaco-workbench .part.statusbar > .statusbar-item a {

View File

@@ -6,16 +6,16 @@
import 'vs/css!./media/statusbarpart';
import * as nls from 'vs/nls';
import { toErrorMessage } from 'vs/base/common/errorMessage';
import { dispose, IDisposable, toDisposable, combinedDisposable, Disposable } from 'vs/base/common/lifecycle';
import { dispose, IDisposable, Disposable } from 'vs/base/common/lifecycle';
import { OcticonLabel } from 'vs/base/browser/ui/octiconLabel/octiconLabel';
import { Registry } from 'vs/platform/registry/common/platform';
import { ICommandService } from 'vs/platform/commands/common/commands';
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
import { Part } from 'vs/workbench/browser/part';
import { IStatusbarRegistry, Extensions, IStatusbarItem } from 'vs/workbench/browser/parts/statusbar/statusbar';
import { IStatusbarRegistry, Extensions } from 'vs/workbench/browser/parts/statusbar/statusbar';
import { IInstantiationService, ServiceIdentifier } from 'vs/platform/instantiation/common/instantiation';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { StatusbarAlignment, IStatusbarService, IStatusbarEntry } from 'vs/platform/statusbar/common/statusbar';
import { StatusbarAlignment, IStatusbarService, IStatusbarEntry, IStatusbarEntryAccessor } from 'vs/platform/statusbar/common/statusbar';
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
import { Action } from 'vs/base/common/actions';
import { IThemeService, registerThemingParticipant, ITheme, ICssStyleCollector, ThemeColor } from 'vs/platform/theme/common/themeService';
@@ -24,11 +24,14 @@ import { IWorkspaceContextService, WorkbenchState } from 'vs/platform/workspace/
import { contrastBorder } from 'vs/platform/theme/common/colorRegistry';
import { isThemeColor } from 'vs/editor/common/editorCommon';
import { Color } from 'vs/base/common/color';
import { addClass, EventHelper, createStyleSheet, addDisposableListener } from 'vs/base/browser/dom';
import { addClass, EventHelper, createStyleSheet, addDisposableListener, addClasses, clearNode, removeClass } from 'vs/base/browser/dom';
import { INotificationService } from 'vs/platform/notification/common/notification';
import { IStorageService } from 'vs/platform/storage/common/storage';
import { Parts, IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/layoutService';
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
import { coalesce } from 'vs/base/common/arrays';
interface PendingEntry { entry: IStatusbarEntry; alignment: StatusbarAlignment; priority: number; accessor?: IStatusbarEntryAccessor; }
export class StatusbarPart extends Part implements IStatusbarService {
@@ -46,10 +49,10 @@ export class StatusbarPart extends Part implements IStatusbarService {
//#endregion
private statusMsgDispose: IDisposable;
private statusMessageDispose: IDisposable;
private styleElement: HTMLStyleElement;
private pendingEntries: { entry: IStatusbarEntry, alignment: StatusbarAlignment, priority: number, disposable: IDisposable }[] = [];
private pendingEntries: PendingEntry[] = [];
constructor(
@IInstantiationService private readonly instantiationService: IInstantiationService,
@@ -67,24 +70,38 @@ export class StatusbarPart extends Part implements IStatusbarService {
this._register(this.contextService.onDidChangeWorkbenchState(() => this.updateStyles()));
}
addEntry(entry: IStatusbarEntry, alignment: StatusbarAlignment, priority: number = 0): IDisposable {
addEntry(entry: IStatusbarEntry, alignment: StatusbarAlignment, priority: number = 0): IStatusbarEntryAccessor {
// As long as we have not been created into a container yet, record all entries
// that are pending so that they can get created at a later point
if (!this.element) {
const pendingEntry = { entry, alignment, priority, disposable: Disposable.None };
const pendingEntry: PendingEntry = {
entry, alignment, priority
};
this.pendingEntries.push(pendingEntry);
return toDisposable(() => {
this.pendingEntries = this.pendingEntries.filter(e => e !== pendingEntry);
pendingEntry.disposable.dispose();
});
const accessor: IStatusbarEntryAccessor = {
update: (entry: IStatusbarEntry) => {
if (pendingEntry.accessor) {
pendingEntry.accessor.update(entry);
} else {
pendingEntry.entry = entry;
}
},
dispose: () => {
if (pendingEntry.accessor) {
pendingEntry.accessor.dispose();
} else {
this.pendingEntries = this.pendingEntries.filter(entry => entry !== pendingEntry);
}
}
};
return accessor;
}
// Render entry in status bar
const el = this.doCreateStatusItem(alignment, priority, entry.showBeak ? 'has-beak' : undefined);
const item = this.instantiationService.createInstance(StatusBarEntryItem, entry);
const toDispose = item.render(el);
const el = this.doCreateStatusItem(alignment, priority, ...coalesce(['statusbar-entry', entry.showBeak ? 'has-beak' : undefined]));
const item = this.instantiationService.createInstance(StatusBarEntryItem, el, entry);
// Insert according to priority
const container = this.element;
@@ -106,13 +123,24 @@ export class StatusbarPart extends Part implements IStatusbarService {
container.appendChild(el);
}
return toDisposable(() => {
el.remove();
return {
update: entry => {
if (toDispose) {
toDispose.dispose();
// Update beak
if (entry.showBeak) {
addClass(el, 'has-beak');
} else {
removeClass(el, 'has-beak');
}
// Update entry
item.update(entry);
},
dispose: () => {
el.remove();
dispose(item);
}
});
};
}
private getEntries(alignment: StatusbarAlignment): HTMLElement[] {
@@ -164,7 +192,7 @@ export class StatusbarPart extends Part implements IStatusbarService {
while (this.pendingEntries.length) {
const entry = this.pendingEntries.shift();
if (entry) {
entry.disposable = this.addEntry(entry.entry, entry.alignment, entry.priority);
entry.accessor = this.addEntry(entry.entry, entry.alignment, entry.priority);
}
}
@@ -195,11 +223,11 @@ export class StatusbarPart extends Part implements IStatusbarService {
this.styleElement.innerHTML = `.monaco-workbench .part.statusbar > .statusbar-item.has-beak:before { border-bottom-color: ${backgroundColor}; }`;
}
private doCreateStatusItem(alignment: StatusbarAlignment, priority: number = 0, extraClass?: string): HTMLElement {
private doCreateStatusItem(alignment: StatusbarAlignment, priority: number = 0, ...extraClasses: string[]): HTMLElement {
const el = document.createElement('div');
addClass(el, 'statusbar-item');
if (extraClass) {
addClass(el, extraClass);
if (extraClasses) {
addClasses(el, ...extraClasses);
}
if (alignment === StatusbarAlignment.RIGHT) {
@@ -215,20 +243,20 @@ export class StatusbarPart extends Part implements IStatusbarService {
}
setStatusMessage(message: string, autoDisposeAfter: number = -1, delayBy: number = 0): IDisposable {
if (this.statusMsgDispose) {
this.statusMsgDispose.dispose(); // dismiss any previous
}
// Dismiss any previous
dispose(this.statusMessageDispose);
// Create new
let statusDispose: IDisposable;
let statusMessageEntry: IStatusbarEntryAccessor;
let showHandle: any = setTimeout(() => {
statusDispose = this.addEntry({ text: message }, StatusbarAlignment.LEFT, -Number.MAX_VALUE /* far right on left hand side */);
statusMessageEntry = this.addEntry({ text: message }, StatusbarAlignment.LEFT, -Number.MAX_VALUE /* far right on left hand side */);
showHandle = null;
}, delayBy);
let hideHandle: any;
// Dispose function takes care of timeouts and actual entry
const dispose = {
const statusMessageDispose = {
dispose: () => {
if (showHandle) {
clearTimeout(showHandle);
@@ -238,18 +266,18 @@ export class StatusbarPart extends Part implements IStatusbarService {
clearTimeout(hideHandle);
}
if (statusDispose) {
statusDispose.dispose();
if (statusMessageEntry) {
statusMessageEntry.dispose();
}
}
};
this.statusMsgDispose = dispose;
this.statusMessageDispose = statusMessageDispose;
if (typeof autoDisposeAfter === 'number' && autoDisposeAfter > 0) {
hideHandle = setTimeout(() => dispose.dispose(), autoDisposeAfter);
hideHandle = setTimeout(() => statusMessageDispose.dispose(), autoDisposeAfter);
}
return dispose;
return statusMessageDispose;
}
layout(width: number, height: number): void {
@@ -264,10 +292,12 @@ export class StatusbarPart extends Part implements IStatusbarService {
}
let manageExtensionAction: ManageExtensionAction;
class StatusBarEntryItem implements IStatusbarItem {
class StatusBarEntryItem extends Disposable {
private entryDisposables: IDisposable[] = [];
constructor(
private entry: IStatusbarEntry,
private container: HTMLElement,
entry: IStatusbarEntry,
@ICommandService private readonly commandService: ICommandService,
@IInstantiationService private readonly instantiationService: IInstantiationService,
@INotificationService private readonly notificationService: INotificationService,
@@ -276,78 +306,80 @@ class StatusBarEntryItem implements IStatusbarItem {
@IEditorService private readonly editorService: IEditorService,
@IThemeService private readonly themeService: IThemeService
) {
this.entry = entry;
super();
if (!manageExtensionAction) {
manageExtensionAction = this.instantiationService.createInstance(ManageExtensionAction);
}
this.render(entry);
}
render(el: HTMLElement): IDisposable {
let toDispose: IDisposable[] = [];
addClass(el, 'statusbar-entry');
update(entry: IStatusbarEntry): void {
clearNode(this.container);
this.entryDisposables = dispose(this.entryDisposables);
this.render(entry);
}
private render(entry: IStatusbarEntry): void {
// Text Container
let textContainer: HTMLElement;
if (this.entry.command) {
if (entry.command) {
textContainer = document.createElement('a');
toDispose.push(addDisposableListener(textContainer, 'click', () => this.executeCommand(this.entry.command!, this.entry.arguments)));
this.entryDisposables.push((addDisposableListener(textContainer, 'click', () => this.executeCommand(entry.command!, entry.arguments))));
} else {
textContainer = document.createElement('span');
}
// Label
new OcticonLabel(textContainer).text = this.entry.text;
new OcticonLabel(textContainer).text = entry.text;
// Tooltip
if (this.entry.tooltip) {
textContainer.title = this.entry.tooltip;
if (entry.tooltip) {
textContainer.title = entry.tooltip;
}
// Color (only applies to text container)
toDispose.push(this.applyColor(textContainer, this.entry.color));
this.applyColor(textContainer, entry.color);
// Background Color (applies to parent element to fully fill container)
if (this.entry.backgroundColor) {
toDispose.push(this.applyColor(el, this.entry.backgroundColor, true));
addClass(el, 'has-background-color');
if (entry.backgroundColor) {
this.applyColor(this.container, entry.backgroundColor, true);
addClass(this.container, 'has-background-color');
}
// Context Menu
if (this.entry.extensionId) {
toDispose.push(addDisposableListener(textContainer, 'contextmenu', e => {
if (entry.extensionId) {
this.entryDisposables.push((addDisposableListener(textContainer, 'contextmenu', e => {
EventHelper.stop(e, true);
this.contextMenuService.showContextMenu({
getAnchor: () => el,
getActionsContext: () => this.entry.extensionId!.value,
getAnchor: () => this.container,
getActionsContext: () => entry.extensionId!.value,
getActions: () => [manageExtensionAction]
});
}));
})));
}
el.appendChild(textContainer);
return toDisposable(() => toDispose = dispose(toDispose));
this.container.appendChild(textContainer);
}
private applyColor(container: HTMLElement, color: string | ThemeColor | undefined, isBackground?: boolean): IDisposable {
const disposable: IDisposable[] = [];
private applyColor(container: HTMLElement, color: string | ThemeColor | undefined, isBackground?: boolean): void {
if (color) {
if (isThemeColor(color)) {
const colorId = color.id;
color = (this.themeService.getTheme().getColor(colorId) || Color.transparent).toString();
disposable.push(this.themeService.onThemeChange(theme => {
this.entryDisposables.push(((this.themeService.onThemeChange(theme => {
const colorValue = (theme.getColor(colorId) || Color.transparent).toString();
isBackground ? container.style.backgroundColor = colorValue : container.style.color = colorValue;
}));
}))));
}
isBackground ? container.style.backgroundColor = color : container.style.color = color;
}
return combinedDisposable(disposable);
}
private executeCommand(id: string, args?: unknown[]) {
@@ -368,6 +400,12 @@ class StatusBarEntryItem implements IStatusbarItem {
this.telemetryService.publicLog('workbenchActionExecuted', { id, from: 'status bar' });
this.commandService.executeCommand(id, ...args).then(undefined, err => this.notificationService.error(toErrorMessage(err)));
}
dispose(): void {
super.dispose();
this.entryDisposables = dispose(this.entryDisposables);
}
}
class ManageExtensionAction extends Action {

View File

@@ -312,7 +312,7 @@ export class MenubarControl extends Disposable {
// Send menus to main process to be rendered by Electron
const menubarData = { menus: {}, keybindings: {} };
if (this.getMenubarMenus(menubarData)) {
this.menubarService.updateMenubar(this.windowService.getCurrentWindowId(), menubarData);
this.menubarService.updateMenubar(this.windowService.windowId, menubarData);
}
}
}
@@ -440,7 +440,7 @@ export class MenubarControl extends Disposable {
return null;
case StateType.Idle:
const windowId = this.windowService.getCurrentWindowId();
const windowId = this.windowService.windowId;
return new Action('update.check', nls.localize({ key: 'checkForUpdates', comment: ['&& denotes a mnemonic'] }, "Check for &&Updates..."), undefined, true, () =>
this.updateService.checkForUpdates({ windowId }));

View File

@@ -18,7 +18,7 @@ import { IEditorService } from 'vs/workbench/services/editor/common/editorServic
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import * as nls from 'vs/nls';
import { EditorInput, toResource, Verbosity, SideBySideEditor } from 'vs/workbench/common/editor';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
import { IWorkspaceContextService, WorkbenchState } from 'vs/platform/workspace/common/workspace';
import { IThemeService, registerThemingParticipant, ITheme, ICssStyleCollector } from 'vs/platform/theme/common/themeService';
import { TITLE_BAR_ACTIVE_BACKGROUND, TITLE_BAR_ACTIVE_FOREGROUND, TITLE_BAR_INACTIVE_FOREGROUND, TITLE_BAR_INACTIVE_BACKGROUND, TITLE_BAR_BORDER } from 'vs/workbench/common/theme';
@@ -85,7 +85,7 @@ export class TitlebarPart extends Part implements ITitleService {
@IConfigurationService private readonly configurationService: IConfigurationService,
@IWindowsService private readonly windowsService: IWindowsService,
@IEditorService private readonly editorService: IEditorService,
@IEnvironmentService private readonly environmentService: IEnvironmentService,
@IWorkbenchEnvironmentService private readonly environmentService: IWorkbenchEnvironmentService,
@IWorkspaceContextService private readonly contextService: IWorkspaceContextService,
@IInstantiationService private readonly instantiationService: IInstantiationService,
@IThemeService themeService: IThemeService,
@@ -412,7 +412,7 @@ export class TitlebarPart extends Part implements ITitleService {
// Resizer
this.resizer = append(this.element, $('div.resizer'));
const isMaximized = this.windowService.getConfiguration().maximized ? true : false;
const isMaximized = this.environmentService.configuration.maximized ? true : false;
this.onDidChangeMaximized(isMaximized);
this.windowService.onDidChangeMaximize(this.onDidChangeMaximized, this);
}

View File

@@ -66,6 +66,7 @@ export abstract class ViewletPanel extends Panel implements IView {
protected actionRunner?: IActionRunner;
protected toolbar: ToolBar;
private headerContainer: HTMLElement;
private titleContainer: HTMLElement;
constructor(
options: IViewletPanelOptions,
@@ -141,7 +142,12 @@ export abstract class ViewletPanel extends Panel implements IView {
}
protected renderHeaderTitle(container: HTMLElement, title: string): void {
append(container, $('h3.title', undefined, title));
this.titleContainer = append(container, $('h3.title', undefined, title));
}
protected updateTitle(title: string): void {
this.titleContainer.textContent = title;
this._onDidChangeTitleArea.fire();
}
focus(): void {

View File

@@ -200,7 +200,11 @@ export class Workbench extends Layout {
// TODO@Ben legacy file service
const fileService = accessor.get(IFileService) as any;
if (typeof fileService.setLegacyService === 'function') {
fileService.setLegacyService(accessor.get(ILegacyFileService));
try {
fileService.setLegacyService(accessor.get(ILegacyFileService));
} catch (error) {
//ignore, legacy file service might not be registered
}
}
// TODO@Sandeep debt around cyclic dependencies
@@ -391,7 +395,7 @@ export class Workbench extends Layout {
// Restore Zen Mode
if (this.state.zenMode.restore) {
this.toggleZenMode(true, true);
this.toggleZenMode(false, true);
}
// Restore Editor Center Mode