提交 fbb088bb 编写于 作者: J Joao Moreno

Merge branch 'master' of github.com:Microsoft/vscode

......@@ -10,21 +10,16 @@ import { CancellationToken } from 'vs/base/common/cancellation';
import { ResolvedKeybinding } from 'vs/base/common/keyCodes';
import URI from 'vs/base/common/uri';
import { Event } from 'vs/base/common/event';
import { FileKind } from 'vs/platform/files/common/files';
export interface IQuickPickItem {
id?: string;
label: string;
description?: string;
detail?: string;
iconClasses?: string[];
picked?: boolean;
}
export interface IFilePickItem extends IQuickPickItem {
resource: URI;
fileKind?: FileKind;
}
export interface IQuickNavigateConfiguration {
keybindings: ResolvedKeybinding[];
}
......
......@@ -48,6 +48,9 @@ export class OpenFolderAPICommand {
if (!uri) {
return executor.executeCommand('_files.pickFolderAndOpen', forceNewWindow);
}
if (!uri.scheme) {
throw new Error(`Invalid URI, schema required: '${uri.toString()}'.`);
}
return executor.executeCommand('_files.windowOpen', [uri], forceNewWindow);
}
......
......@@ -23,7 +23,10 @@ import { IEnvironmentService } from 'vs/platform/environment/common/environment'
import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
import { isLinux } from 'vs/base/common/platform';
import { IUriDisplayService } from 'vs/platform/uriDisplay/common/uriDisplay';
import { IQuickInputService, IPickOptions, IFilePickItem } from 'vs/platform/quickinput/common/quickInput';
import { IQuickInputService, IPickOptions, IQuickPickItem } from 'vs/platform/quickinput/common/quickInput';
import { getIconClasses } from 'vs/workbench/browser/labels';
import { IModelService } from 'vs/editor/common/services/modelService';
import { IModeService } from 'vs/editor/common/services/modeService';
export const ADD_ROOT_FOLDER_COMMAND_ID = 'addRootFolder';
export const ADD_ROOT_FOLDER_LABEL = nls.localize('addFolderToWorkspace', "Add Folder to Workspace...");
......@@ -158,10 +161,12 @@ CommandsRegistry.registerCommand({
}
});
CommandsRegistry.registerCommand(PICK_WORKSPACE_FOLDER_COMMAND_ID, function (accessor, args?: [IPickOptions<IFilePickItem>, CancellationToken]) {
CommandsRegistry.registerCommand(PICK_WORKSPACE_FOLDER_COMMAND_ID, function (accessor, args?: [IPickOptions<IQuickPickItem>, CancellationToken]) {
const quickInputService = accessor.get(IQuickInputService);
const uriDisplayService = accessor.get(IUriDisplayService);
const contextService = accessor.get(IWorkspaceContextService);
const modelService = accessor.get(IModelService);
const modeService = accessor.get(IModeService);
const folders = contextService.getWorkspace().folders;
if (!folders.length) {
......@@ -173,12 +178,11 @@ CommandsRegistry.registerCommand(PICK_WORKSPACE_FOLDER_COMMAND_ID, function (acc
label: folder.name,
description: uriDisplayService.getLabel(resources.dirname(folder.uri), true),
folder,
resource: folder.uri,
fileKind: FileKind.ROOT_FOLDER
} as IFilePickItem;
iconClasses: getIconClasses(modelService, modeService, folder.uri, FileKind.ROOT_FOLDER)
} as IQuickPickItem;
});
let options: IPickOptions<IFilePickItem>;
let options: IPickOptions<IQuickPickItem>;
if (args) {
options = args[0];
}
......
......@@ -8,7 +8,6 @@
import 'vs/css!./media/activitybarpart';
import * as nls from 'vs/nls';
import { illegalArgument } from 'vs/base/common/errors';
import { $ } from 'vs/base/browser/builder';
import { ActionsOrientation, ActionBar } from 'vs/base/browser/ui/actionbar/actionbar';
import { GlobalActivityExtensions, IGlobalActivityRegistry } from 'vs/workbench/common/activity';
import { Registry } from 'vs/platform/registry/common/platform';
......@@ -26,7 +25,7 @@ import { contrastBorder } from 'vs/platform/theme/common/colorRegistry';
import { CompositeBar } from 'vs/workbench/browser/parts/compositebar/compositeBar';
import { isMacintosh } from 'vs/base/common/platform';
import { ILifecycleService, LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';
import { scheduleAtNextAnimationFrame, Dimension } from 'vs/base/browser/dom';
import { scheduleAtNextAnimationFrame, Dimension, addClass } from 'vs/base/browser/dom';
import { Color } from 'vs/base/common/color';
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions';
......@@ -156,14 +155,19 @@ export class ActivitybarPart extends Part {
}
createContentArea(parent: HTMLElement): HTMLElement {
const $el = $(parent);
const $result = $('.content').appendTo($el);
const content = document.createElement('div');
addClass(content, 'content');
parent.appendChild(content);
// Top Actionbar with action items for each viewlet action
this.compositeBar.create($result.getHTMLElement());
this.compositeBar.create(content);
// Top Actionbar with action items for each viewlet action
this.createGlobalActivityActionBar($('.global-activity').appendTo($result).getHTMLElement());
const globalActivities = document.createElement('div');
addClass(globalActivities, 'global-activity');
content.appendChild(globalActivities);
this.createGlobalActivityActionBar(globalActivities);
// TODO@Ben: workaround for https://github.com/Microsoft/vscode/issues/45700
// It looks like there are rendering glitches on macOS with Chrome 61 when
......@@ -186,26 +190,26 @@ export class ActivitybarPart extends Part {
});
}
return $result.getHTMLElement();
return content;
}
updateStyles(): void {
super.updateStyles();
// Part container
const container = $(this.getContainer());
const container = this.getContainer();
const background = this.getColor(ACTIVITY_BAR_BACKGROUND);
container.style('background-color', background);
container.style.backgroundColor = background;
const borderColor = this.getColor(ACTIVITY_BAR_BORDER) || this.getColor(contrastBorder);
const isPositionLeft = this.partService.getSideBarPosition() === SideBarPosition.LEFT;
container.style('box-sizing', borderColor && isPositionLeft ? 'border-box' : null);
container.style('border-right-width', borderColor && isPositionLeft ? '1px' : null);
container.style('border-right-style', borderColor && isPositionLeft ? 'solid' : null);
container.style('border-right-color', isPositionLeft ? borderColor : null);
container.style('border-left-width', borderColor && !isPositionLeft ? '1px' : null);
container.style('border-left-style', borderColor && !isPositionLeft ? 'solid' : null);
container.style('border-left-color', !isPositionLeft ? borderColor : null);
container.style.boxSizing = borderColor && isPositionLeft ? 'border-box' : null;
container.style.borderRightWidth = borderColor && isPositionLeft ? '1px' : null;
container.style.borderRightStyle = borderColor && isPositionLeft ? 'solid' : null;
container.style.borderRightColor = isPositionLeft ? borderColor : null;
container.style.borderLeftWidth = borderColor && !isPositionLeft ? '1px' : null;
container.style.borderLeftStyle = borderColor && !isPositionLeft ? 'solid' : null;
container.style.borderLeftColor = !isPositionLeft ? borderColor : null;
}
private createGlobalActivityActionBar(container: HTMLElement): void {
......
......@@ -7,7 +7,6 @@ import 'vs/css!./media/panelpart';
import { TPromise } from 'vs/base/common/winjs.base';
import { IAction } from 'vs/base/common/actions';
import { Event } from 'vs/base/common/event';
import { $ } from 'vs/base/browser/builder';
import { Registry } from 'vs/platform/registry/common/platform';
import { ActionsOrientation } from 'vs/base/browser/ui/actionbar/actionbar';
import { IPanel } from 'vs/workbench/common/panel';
......@@ -151,12 +150,12 @@ export class PanelPart extends CompositePart<Panel> implements IPanelService {
updateStyles(): void {
super.updateStyles();
const container = $(this.getContainer());
container.style('background-color', this.getColor(PANEL_BACKGROUND));
container.style('border-left-color', this.getColor(PANEL_BORDER) || this.getColor(contrastBorder));
const container = this.getContainer();
container.style.backgroundColor = this.getColor(PANEL_BACKGROUND);
container.style.borderLeftColor = this.getColor(PANEL_BORDER) || this.getColor(contrastBorder);
const title = $(this.getTitleArea());
title.style('border-top-color', this.getColor(PANEL_BORDER) || this.getColor(contrastBorder));
const title = this.getTitleArea();
title.style.borderTopColor = this.getColor(PANEL_BORDER) || this.getColor(contrastBorder);
}
openPanel(id: string, focus?: boolean): TPromise<Panel> {
......
......@@ -182,7 +182,7 @@ class QuickInput implements IQuickInput {
if (this.visible) {
return;
}
this.disposables.push(
this.visibleDisposables.push(
this.ui.onDidTriggerButton(button => {
if (this.buttons.indexOf(button) !== -1) {
this.onDidTriggerButtonEmitter.fire(button);
......@@ -785,7 +785,7 @@ export class QuickInputService extends Component implements IQuickInputService {
}
const workbench = document.getElementById(this.partService.getWorkbenchElementId());
const container = dom.append(workbench, $('.quick-input-widget'));
const container = dom.append(workbench, $('.quick-input-widget.show-file-icons'));
container.tabIndex = -1;
container.style.display = 'none';
......
......@@ -121,6 +121,7 @@ class ListElementRenderer implements IRenderer<ListElement, IListElementTemplate
options.matches = labelHighlights || [];
options.descriptionTitle = element.item.description;
options.descriptionMatches = descriptionHighlights || [];
options.extraClasses = element.item.iconClasses;
data.label.setValue(element.item.label, element.item.description, options);
// Meta
......
......@@ -26,8 +26,7 @@ import { IThemeService } from 'vs/platform/theme/common/themeService';
import { contrastBorder } from 'vs/platform/theme/common/colorRegistry';
import { SIDE_BAR_TITLE_FOREGROUND, SIDE_BAR_BACKGROUND, SIDE_BAR_FOREGROUND, SIDE_BAR_BORDER } from 'vs/workbench/common/theme';
import { INotificationService } from 'vs/platform/notification/common/notification';
import { Dimension, EventType } from 'vs/base/browser/dom';
import { $ } from 'vs/base/browser/builder';
import { Dimension, EventType, addDisposableListener } from 'vs/base/browser/dom';
import { StandardMouseEvent } from 'vs/base/browser/mouseEvent';
export class SidebarPart extends CompositePart<Viewlet> {
......@@ -77,7 +76,10 @@ export class SidebarPart extends CompositePart<Viewlet> {
createTitleArea(parent: HTMLElement): HTMLElement {
const titleArea = super.createTitleArea(parent);
$(titleArea).on(EventType.CONTEXT_MENU, (e: MouseEvent) => this.onTitleAreaContextMenu(new StandardMouseEvent(e)), this.toDispose);
this._register(addDisposableListener(titleArea, EventType.CONTEXT_MENU, e => {
this.onTitleAreaContextMenu(new StandardMouseEvent(e));
}));
return titleArea;
}
......@@ -86,19 +88,19 @@ export class SidebarPart extends CompositePart<Viewlet> {
super.updateStyles();
// Part container
const container = $(this.getContainer());
const container = this.getContainer();
container.style('background-color', this.getColor(SIDE_BAR_BACKGROUND));
container.style('color', this.getColor(SIDE_BAR_FOREGROUND));
container.style.backgroundColor = this.getColor(SIDE_BAR_BACKGROUND);
container.style.color = this.getColor(SIDE_BAR_FOREGROUND);
const borderColor = this.getColor(SIDE_BAR_BORDER) || this.getColor(contrastBorder);
const isPositionLeft = this.partService.getSideBarPosition() === SideBarPosition.LEFT;
container.style('border-right-width', borderColor && isPositionLeft ? '1px' : null);
container.style('border-right-style', borderColor && isPositionLeft ? 'solid' : null);
container.style('border-right-color', isPositionLeft ? borderColor : null);
container.style('border-left-width', borderColor && !isPositionLeft ? '1px' : null);
container.style('border-left-style', borderColor && !isPositionLeft ? 'solid' : null);
container.style('border-left-color', !isPositionLeft ? borderColor : null);
container.style.borderRightWidth = borderColor && isPositionLeft ? '1px' : null;
container.style.borderRightStyle = borderColor && isPositionLeft ? 'solid' : null;
container.style.borderRightColor = isPositionLeft ? borderColor : null;
container.style.borderLeftWidth = borderColor && !isPositionLeft ? '1px' : null;
container.style.borderLeftStyle = borderColor && !isPositionLeft ? 'solid' : null;
container.style.borderLeftColor = !isPositionLeft ? borderColor : null;
}
openViewlet(id: string, focus?: boolean): TPromise<Viewlet> {
......
......@@ -134,22 +134,22 @@ export class StatusbarPart extends Part implements IStatusbarService {
protected updateStyles(): void {
super.updateStyles();
const container = $(this.getContainer());
const container = this.getContainer();
// Background colors
const backgroundColor = this.getColor(this.contextService.getWorkbenchState() !== WorkbenchState.EMPTY ? STATUS_BAR_BACKGROUND : STATUS_BAR_NO_FOLDER_BACKGROUND);
container.style('background-color', backgroundColor);
container.style('color', this.getColor(this.contextService.getWorkbenchState() !== WorkbenchState.EMPTY ? STATUS_BAR_FOREGROUND : STATUS_BAR_NO_FOLDER_FOREGROUND));
container.style.backgroundColor = backgroundColor;
container.style.color = this.getColor(this.contextService.getWorkbenchState() !== WorkbenchState.EMPTY ? STATUS_BAR_FOREGROUND : STATUS_BAR_NO_FOLDER_FOREGROUND);
// Border color
const borderColor = this.getColor(this.contextService.getWorkbenchState() !== WorkbenchState.EMPTY ? STATUS_BAR_BORDER : STATUS_BAR_NO_FOLDER_BORDER) || this.getColor(contrastBorder);
container.style('border-top-width', borderColor ? '1px' : null);
container.style('border-top-style', borderColor ? 'solid' : null);
container.style('border-top-color', borderColor);
container.style.borderTopWidth = borderColor ? '1px' : null;
container.style.borderTopStyle = borderColor ? 'solid' : null;
container.style.borderTopColor = borderColor;
// Notification Beak
if (!this.styleElement) {
this.styleElement = createStyleSheet(container.getHTMLElement());
this.styleElement = createStyleSheet(container);
}
this.styleElement.innerHTML = `.monaco-workbench > .part.statusbar > .statusbar-item.has-beak:before { border-bottom-color: ${backgroundColor}; }`;
......
......@@ -12,7 +12,6 @@ import { TPromise } from 'vs/base/common/winjs.base';
import { IDisposable, dispose, toDisposable, Disposable } from 'vs/base/common/lifecycle';
import { Event, Emitter } from 'vs/base/common/event';
import * as DOM from 'vs/base/browser/dom';
import { Builder, $ } from 'vs/base/browser/builder';
import { RunOnceScheduler } from 'vs/base/common/async';
import * as browser from 'vs/base/browser/browser';
import * as perf from 'vs/base/common/performance';
......@@ -190,7 +189,7 @@ export class Workbench extends Disposable implements IPartService {
_serviceBrand: any;
private workbenchParams: WorkbenchParams;
private workbench: Builder;
private workbench: HTMLElement;
private workbenchStarted: boolean;
private workbenchCreated: boolean;
private workbenchShutdown: boolean;
......@@ -296,12 +295,13 @@ export class Workbench extends Disposable implements IPartService {
}
private createWorkbench(): void {
this.workbench = $().div({
'class': `monaco-workbench ${isWindows ? 'windows' : isLinux ? 'linux' : 'mac'}`,
id: Identifiers.WORKBENCH_CONTAINER
});
this.workbench = document.createElement('div');
this.workbench.id = Identifiers.WORKBENCH_CONTAINER;
DOM.addClasses(this.workbench, 'monaco-workbench', isWindows ? 'windows' : isLinux ? 'linux' : 'mac');
this.workbench.on(DOM.EventType.SCROLL, e => { this.workbench.getHTMLElement().scrollTop = 0; }); // Prevent workbench from scrolling #55456
this._register(DOM.addDisposableListener(this.workbench, DOM.EventType.SCROLL, () => {
this.workbench.scrollTop = 0; // Prevent workbench from scrolling #55456
}));
}
private createGlobalActions(): void {
......@@ -358,7 +358,7 @@ export class Workbench extends Disposable implements IPartService {
serviceCollection.set(IListService, this.instantiationService.createInstance(ListService));
// Context view service
this.contextViewService = this.instantiationService.createInstance(ContextViewService, this.workbench.getHTMLElement());
this.contextViewService = this.instantiationService.createInstance(ContextViewService, this.workbench);
serviceCollection.set(IContextViewService, this.contextViewService);
// Use themable context menus when custom titlebar is enabled to match custom menubar
......@@ -514,9 +514,10 @@ export class Workbench extends Disposable implements IPartService {
// Apply as CSS class
const isFullscreen = browser.isFullscreen();
if (isFullscreen) {
this.workbench.addClass('fullscreen');
DOM.addClass(this.workbench, 'fullscreen');
} else {
this.workbench.removeClass('fullscreen');
DOM.removeClass(this.workbench, 'fullscreen');
if (this.zenMode.transitionedToFullScreen && this.zenMode.active) {
this.toggleZenMode();
}
......@@ -925,9 +926,9 @@ export class Workbench extends Disposable implements IPartService {
// Adjust CSS
if (hidden) {
this.workbench.addClass('nostatusbar');
DOM.addClass(this.workbench, 'nostatusbar');
} else {
this.workbench.removeClass('nostatusbar');
DOM.removeClass(this.workbench, 'nostatusbar');
}
// Layout
......@@ -952,7 +953,7 @@ export class Workbench extends Disposable implements IPartService {
this.workbenchLayout = this.instantiationService.createInstance(
WorkbenchLayout,
this.container,
this.workbench.getHTMLElement(),
this.workbench,
{
titlebar: this.titlebarPart,
activitybar: this.activitybarPart,
......@@ -972,13 +973,15 @@ export class Workbench extends Disposable implements IPartService {
// Apply sidebar state as CSS class
if (this.sideBarHidden) {
this.workbench.addClass('nosidebar');
DOM.addClass(this.workbench, 'nosidebar');
}
if (this.panelHidden) {
this.workbench.addClass('nopanel');
DOM.addClass(this.workbench, 'nopanel');
}
if (this.statusBarHidden) {
this.workbench.addClass('nostatusbar');
DOM.addClass(this.workbench, 'nostatusbar');
}
// Apply font aliasing
......@@ -986,7 +989,7 @@ export class Workbench extends Disposable implements IPartService {
// Apply fullscreen state
if (browser.isFullscreen()) {
this.workbench.addClass('fullscreen');
DOM.addClass(this.workbench, 'fullscreen');
}
// Create Parts
......@@ -1001,80 +1004,63 @@ export class Workbench extends Disposable implements IPartService {
this.createNotificationsHandlers();
// Add Workbench to DOM
this.workbench.appendTo(this.container);
this.container.appendChild(this.workbench);
}
private createTitlebarPart(): void {
const titlebarContainer = $(this.workbench).div({
'class': ['part', 'titlebar'],
id: Identifiers.TITLEBAR_PART,
role: 'contentinfo'
});
const titlebarContainer = this.createPart(Identifiers.TITLEBAR_PART, ['part', 'titlebar'], 'contentinfo');
this.titlebarPart.create(titlebarContainer.getHTMLElement());
this.titlebarPart.create(titlebarContainer);
}
private createActivityBarPart(): void {
const activitybarPartContainer = $(this.workbench)
.div({
'class': ['part', 'activitybar', this.sideBarPosition === Position.LEFT ? 'left' : 'right'],
id: Identifiers.ACTIVITYBAR_PART,
role: 'navigation'
});
const activitybarPartContainer = this.createPart(Identifiers.ACTIVITYBAR_PART, ['part', 'activitybar', this.sideBarPosition === Position.LEFT ? 'left' : 'right'], 'navigation');
this.activitybarPart.create(activitybarPartContainer.getHTMLElement());
this.activitybarPart.create(activitybarPartContainer);
}
private createSidebarPart(): void {
const sidebarPartContainer = $(this.workbench)
.div({
'class': ['part', 'sidebar', this.sideBarPosition === Position.LEFT ? 'left' : 'right'],
id: Identifiers.SIDEBAR_PART,
role: 'complementary'
});
const sidebarPartContainer = this.createPart(Identifiers.SIDEBAR_PART, ['part', 'sidebar', this.sideBarPosition === Position.LEFT ? 'left' : 'right'], 'complementary');
this.sidebarPart.create(sidebarPartContainer.getHTMLElement());
this.sidebarPart.create(sidebarPartContainer);
}
private createPanelPart(): void {
const panelPartContainer = $(this.workbench)
.div({
'class': ['part', 'panel', this.panelPosition === Position.BOTTOM ? 'bottom' : 'right'],
id: Identifiers.PANEL_PART,
role: 'complementary'
});
const panelPartContainer = this.createPart(Identifiers.PANEL_PART, ['part', 'panel', this.panelPosition === Position.BOTTOM ? 'bottom' : 'right'], 'complementary');
this.panelPart.create(panelPartContainer.getHTMLElement());
this.panelPart.create(panelPartContainer);
}
private createEditorPart(): void {
const editorContainer = $(this.workbench)
.div({
'class': ['part', 'editor'],
id: Identifiers.EDITOR_PART,
role: 'main'
});
const editorContainer = this.createPart(Identifiers.EDITOR_PART, ['part', 'editor'], 'main');
this.editorPart.create(editorContainer.getHTMLElement());
this.editorPart.create(editorContainer);
}
private createStatusbarPart(): void {
const statusbarContainer = $(this.workbench).div({
'class': ['part', 'statusbar'],
id: Identifiers.STATUSBAR_PART,
role: 'contentinfo'
});
const statusbarContainer = this.createPart(Identifiers.STATUSBAR_PART, ['part', 'statusbar'], 'contentinfo');
this.statusbarPart.create(statusbarContainer);
}
private createPart(id: string, classes: string[], role: string): HTMLElement {
const part = document.createElement('div');
classes.forEach(clazz => DOM.addClass(part, clazz));
part.id = id;
part.setAttribute('role', role);
this.workbench.appendChild(part);
this.statusbarPart.create(statusbarContainer.getHTMLElement());
return part;
}
private createNotificationsHandlers(): void {
// Notifications Center
this.notificationsCenter = this._register(this.instantiationService.createInstance(NotificationsCenter, this.workbench.getHTMLElement(), this.notificationService.model));
this.notificationsCenter = this._register(this.instantiationService.createInstance(NotificationsCenter, this.workbench, this.notificationService.model));
// Notifications Toasts
this.notificationsToasts = this._register(this.instantiationService.createInstance(NotificationsToasts, this.workbench.getHTMLElement(), this.notificationService.model));
this.notificationsToasts = this._register(this.instantiationService.createInstance(NotificationsToasts, this.workbench, this.notificationService.model));
// Notifications Alerts
this._register(this.instantiationService.createInstance(NotificationsAlerts, this.notificationService.model));
......@@ -1324,9 +1310,9 @@ export class Workbench extends Disposable implements IPartService {
// Adjust CSS
if (hidden) {
this.workbench.addClass('nosidebar');
DOM.addClass(this.workbench, 'nosidebar');
} else {
this.workbench.removeClass('nosidebar');
DOM.removeClass(this.workbench, 'nosidebar');
}
// If sidebar becomes hidden, also hide the current active Viewlet if any
......@@ -1375,9 +1361,9 @@ export class Workbench extends Disposable implements IPartService {
// Adjust CSS
if (hidden) {
this.workbench.addClass('nopanel');
DOM.addClass(this.workbench, 'nopanel');
} else {
this.workbench.removeClass('nopanel');
DOM.removeClass(this.workbench, 'nopanel');
}
// If panel part becomes hidden, also hide the current active panel if any
......
......@@ -30,7 +30,6 @@ import { IWindowService } from 'vs/platform/windows/common/windows';
import { ReleaseNotesManager } from './releaseNotesEditor';
import { isWindows } from 'vs/base/common/platform';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import * as Registry from 'winreg';
let releaseNotesManager: ReleaseNotesManager | undefined = undefined;
......@@ -213,6 +212,7 @@ export class Win3264BitContribution implements IWorkbenchContribution {
async function isUserSetupInstalled(): Promise<boolean> {
const rawUserAppId = process.arch === 'x64' ? product.win32x64UserAppId : product.win32UserAppId;
const userAppId = rawUserAppId.replace(/^\{\{/, '{');
const Registry = await import('winreg');
const key = new Registry({
hive: Registry.HKCU,
key: `\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\${userAppId}_is1`
......@@ -251,6 +251,33 @@ export class WinUserSetupContribution implements IWorkbenchContribution {
) {
updateService.onStateChange(this.onUpdateStateChange, this, this.disposables);
this.onUpdateStateChange(this.updateService.state);
const neverShowAgain = new NeverShowAgain(WinUserSetupContribution.KEY_BOTH, this.storageService);
if (!neverShowAgain.shouldShow()) {
return;
}
isUserSetupInstalled().then(userSetupIsInstalled => {
if (!userSetupIsInstalled) {
return;
}
const handle = this.notificationService.prompt(
severity.Warning,
nls.localize('usersetupsystem', "You are running the system-wide installation of {0}, while having the user-wide distribution installed as well. Make sure you're running the {0} version you expect.", product.nameShort),
[
{ label: nls.localize('ok', "OK"), run: () => null },
{
label: nls.localize('neveragain', "Don't Show Again"),
isSecondary: true,
run: () => {
neverShowAgain.action.run(handle);
neverShowAgain.action.dispose();
}
}]
);
});
}
private onUpdateStateChange(state: UpdateState): void {
......@@ -266,63 +293,35 @@ export class WinUserSetupContribution implements IWorkbenchContribution {
return;
}
isUserSetupInstalled().then(userSetupIsInstalled => {
if (userSetupIsInstalled) {
const neverShowAgain = new NeverShowAgain(WinUserSetupContribution.KEY_BOTH, this.storageService);
if (!neverShowAgain.shouldShow()) {
return;
}
const handle = this.notificationService.prompt(
severity.Warning,
nls.localize('usersetupsystem', "You are running the system-wide installation of {0}, while having the user-wide distribution installed as well. Make sure you're running the {0} version you expect.", product.nameShort),
[
{
label: nls.localize('ok', "OK"),
run: () => null
},
{
label: nls.localize('neveragain', "Don't Show Again"),
isSecondary: true,
run: () => {
neverShowAgain.action.run(handle);
neverShowAgain.action.dispose();
}
}]
);
} else {
const neverShowAgain = new NeverShowAgain(WinUserSetupContribution.KEY, this.storageService);
if (!neverShowAgain.shouldShow()) {
return;
}
const neverShowAgain = new NeverShowAgain(WinUserSetupContribution.KEY, this.storageService);
const handle = this.notificationService.prompt(
severity.Info,
nls.localize('usersetup', "We recommend switching to our new User Setup distribution of {0} for Windows! Click [here]({1}) to learn more.", product.nameShort, WinUserSetupContribution.READ_MORE),
[
{
label: nls.localize('downloadnow', "Download"),
run: () => {
const url = product.quality === 'insider'
? (process.arch === 'ia32' ? WinUserSetupContribution.INSIDER_URL_32BIT : WinUserSetupContribution.INSIDER_URL)
: (process.arch === 'ia32' ? WinUserSetupContribution.STABLE_URL_32BIT : WinUserSetupContribution.STABLE_URL);
if (!neverShowAgain.shouldShow()) {
return;
}
return this.openerService.open(URI.parse(url));
}
},
{
label: nls.localize('neveragain', "Don't Show Again"),
isSecondary: true,
run: () => {
neverShowAgain.action.run(handle);
neverShowAgain.action.dispose();
}
}]
);
}
});
const handle = this.notificationService.prompt(
severity.Info,
nls.localize('usersetup', "We recommend switching to our new User Setup distribution of {0} for Windows! Click [here]({1}) to learn more.", product.nameShort, WinUserSetupContribution.READ_MORE),
[
{
label: nls.localize('downloadnow', "Download"),
run: () => {
const url = product.quality === 'insider'
? (process.arch === 'ia32' ? WinUserSetupContribution.INSIDER_URL_32BIT : WinUserSetupContribution.INSIDER_URL)
: (process.arch === 'ia32' ? WinUserSetupContribution.STABLE_URL_32BIT : WinUserSetupContribution.STABLE_URL);
return this.openerService.open(URI.parse(url));
}
},
{
label: nls.localize('neveragain', "Don't Show Again"),
isSecondary: true,
run: () => {
neverShowAgain.action.run(handle);
neverShowAgain.action.dispose();
}
}]
);
}
dispose(): void {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册