mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
Merge from vscode c58aaab8a1cc22a7139b761166a0d4f37d41e998 (#7880)
* Merge from vscode c58aaab8a1cc22a7139b761166a0d4f37d41e998 * fix pipelines * fix strict-null-checks * add missing files
This commit is contained in:
@@ -46,10 +46,10 @@ Registry.add(Extensions.WorkbenchActions, new class implements IWorkbenchActionR
|
||||
weight: weight,
|
||||
when: (descriptor.keybindingContext || when ? ContextKeyExpr.and(descriptor.keybindingContext, when) : null),
|
||||
primary: keybindings ? keybindings.primary : 0,
|
||||
secondary: keybindings && keybindings.secondary,
|
||||
win: keybindings && keybindings.win,
|
||||
mac: keybindings && keybindings.mac,
|
||||
linux: keybindings && keybindings.linux
|
||||
secondary: keybindings?.secondary,
|
||||
win: keybindings?.win,
|
||||
mac: keybindings?.mac,
|
||||
linux: keybindings?.linux
|
||||
});
|
||||
|
||||
// menu item
|
||||
@@ -112,7 +112,7 @@ Registry.add(Extensions.WorkbenchActions, new class implements IWorkbenchActionR
|
||||
|
||||
// otherwise run and dispose
|
||||
try {
|
||||
const from = args && args.from || 'keybinding';
|
||||
const from = args?.from || 'keybinding';
|
||||
await actionInstance.run(undefined, { from });
|
||||
} finally {
|
||||
actionInstance.dispose();
|
||||
|
||||
@@ -63,11 +63,11 @@ class WorkbenchContributionsRegistry implements IWorkbenchContributionsRegistry
|
||||
}
|
||||
|
||||
start(accessor: ServicesAccessor): void {
|
||||
this.instantiationService = accessor.get(IInstantiationService);
|
||||
this.lifecycleService = accessor.get(ILifecycleService);
|
||||
const instantiationService = this.instantiationService = accessor.get(IInstantiationService);
|
||||
const lifecycleService = this.lifecycleService = accessor.get(ILifecycleService);
|
||||
|
||||
[LifecyclePhase.Starting, LifecyclePhase.Ready, LifecyclePhase.Restored, LifecyclePhase.Eventually].forEach(phase => {
|
||||
this.instantiateByPhase(this.instantiationService!, this.lifecycleService!, phase);
|
||||
this.instantiateByPhase(instantiationService, lifecycleService, phase);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ class WorkbenchContributionsRegistry implements IWorkbenchContributionsRegistry
|
||||
try {
|
||||
instantiationService.createInstance(ctor);
|
||||
} catch (error) {
|
||||
console.error(`Unable to instantiate workbench contribution ${ctor}.`, error);
|
||||
console.error(`Unable to instantiate workbench contribution ${(ctor as any).name}.`, error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,11 +5,11 @@
|
||||
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
import { assign } from 'vs/base/common/objects';
|
||||
import { isUndefinedOrNull } from 'vs/base/common/types';
|
||||
import { isUndefinedOrNull, withNullAsUndefined, assertIsDefined } from 'vs/base/common/types';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { IDisposable, Disposable } from 'vs/base/common/lifecycle';
|
||||
import { IEditor as ICodeEditor, IEditorViewState, ScrollType, IDiffEditor } from 'vs/editor/common/editorCommon';
|
||||
import { IEditorModel, IEditorOptions, ITextEditorOptions, IBaseResourceInput, IResourceInput, EditorActivation } from 'vs/platform/editor/common/editor';
|
||||
import { IEditorModel, IEditorOptions, ITextEditorOptions, IBaseResourceInput, IResourceInput, EditorActivation, EditorOpenContext } from 'vs/platform/editor/common/editor';
|
||||
import { IInstantiationService, IConstructorSignature0, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { RawContextKey, ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
@@ -38,6 +38,7 @@ export const SingleEditorGroupsContext = MultipleEditorGroupsContext.toNegated()
|
||||
export const InEditorZenModeContext = new RawContextKey<boolean>('inZenMode', false);
|
||||
export const IsCenteredLayoutContext = new RawContextKey<boolean>('isCenteredLayout', false);
|
||||
export const SplitEditorsVertically = new RawContextKey<boolean>('splitEditorsVertically', false);
|
||||
export const EditorAreaVisibleContext = new RawContextKey<boolean>('editorAreaVisible', true);
|
||||
|
||||
/**
|
||||
* Text diff editor id.
|
||||
@@ -117,7 +118,7 @@ export interface ITextEditor extends IEditor {
|
||||
/**
|
||||
* Returns the underlying text editor widget of this editor.
|
||||
*/
|
||||
getControl(): ICodeEditor;
|
||||
getControl(): ICodeEditor | undefined;
|
||||
}
|
||||
|
||||
export interface ITextDiffEditor extends IEditor {
|
||||
@@ -125,7 +126,7 @@ export interface ITextDiffEditor extends IEditor {
|
||||
/**
|
||||
* Returns the underlying text editor widget of this editor.
|
||||
*/
|
||||
getControl(): IDiffEditor;
|
||||
getControl(): IDiffEditor | undefined;
|
||||
}
|
||||
|
||||
export interface ITextSideBySideEditor extends IEditor {
|
||||
@@ -510,7 +511,7 @@ export interface IEncodingSupport {
|
||||
/**
|
||||
* Gets the encoding of the input if known.
|
||||
*/
|
||||
getEncoding(): string;
|
||||
getEncoding(): string | undefined;
|
||||
|
||||
/**
|
||||
* Sets the encoding for the input for saving.
|
||||
@@ -786,6 +787,18 @@ export class EditorOptions implements IEditorOptions {
|
||||
*/
|
||||
ignoreOverrides: boolean | undefined;
|
||||
|
||||
/**
|
||||
* A optional hint to signal in which context the editor opens.
|
||||
*
|
||||
* If configured to be `EditorOpenContext.USER`, this hint can be
|
||||
* used in various places to control the experience. For example,
|
||||
* if the editor to open fails with an error, a notification could
|
||||
* inform about this in a modal dialog. If the editor opened through
|
||||
* some background task, the notification would show in the background,
|
||||
* not as a modal dialog.
|
||||
*/
|
||||
context: EditorOpenContext | undefined;
|
||||
|
||||
/**
|
||||
* Overwrites option values from the provided bag.
|
||||
*/
|
||||
@@ -830,6 +843,10 @@ export class EditorOptions implements IEditorOptions {
|
||||
this.ignoreOverrides = options.ignoreOverrides;
|
||||
}
|
||||
|
||||
if (typeof options.context === 'number') {
|
||||
this.context = options.context;
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -838,13 +855,13 @@ export class EditorOptions implements IEditorOptions {
|
||||
* Base Text Editor Options.
|
||||
*/
|
||||
export class TextEditorOptions extends EditorOptions {
|
||||
private startLineNumber: number;
|
||||
private startColumn: number;
|
||||
private endLineNumber: number;
|
||||
private endColumn: number;
|
||||
private startLineNumber: number | undefined;
|
||||
private startColumn: number | undefined;
|
||||
private endLineNumber: number | undefined;
|
||||
private endColumn: number | undefined;
|
||||
|
||||
private revealInCenterIfOutsideViewport: boolean;
|
||||
private editorViewState: IEditorViewState | null;
|
||||
private revealInCenterIfOutsideViewport: boolean | undefined;
|
||||
private editorViewState: IEditorViewState | undefined;
|
||||
|
||||
static from(input?: IBaseResourceInput): TextEditorOptions | undefined {
|
||||
if (!input || !input.options) {
|
||||
@@ -912,7 +929,7 @@ export class TextEditorOptions extends EditorOptions {
|
||||
const options = TextEditorOptions.create(settings);
|
||||
|
||||
// View state
|
||||
options.editorViewState = editor.saveViewState();
|
||||
options.editorViewState = withNullAsUndefined(editor.saveViewState());
|
||||
|
||||
return options;
|
||||
}
|
||||
@@ -1036,6 +1053,7 @@ interface IEditorPartConfiguration {
|
||||
mouseBackForwardToNavigate?: boolean;
|
||||
labelFormat?: 'default' | 'short' | 'medium' | 'long';
|
||||
restoreViewState?: boolean;
|
||||
splitSizing?: 'split' | 'distribute';
|
||||
}
|
||||
|
||||
export interface IEditorPartOptions extends IEditorPartConfiguration {
|
||||
@@ -1057,7 +1075,7 @@ export function toResource(editor: IEditorInput | undefined, options?: IResource
|
||||
return undefined;
|
||||
}
|
||||
|
||||
if (options && options.supportSideBySide && editor instanceof SideBySideEditorInput) {
|
||||
if (options?.supportSideBySide && editor instanceof SideBySideEditorInput) {
|
||||
editor = options.supportSideBySide === SideBySideEditor.MASTER ? editor.master : editor.details;
|
||||
}
|
||||
|
||||
@@ -1095,23 +1113,23 @@ export interface IEditorMemento<T> {
|
||||
}
|
||||
|
||||
class EditorInputFactoryRegistry implements IEditorInputFactoryRegistry {
|
||||
private instantiationService: IInstantiationService;
|
||||
private fileInputFactory: IFileInputFactory;
|
||||
private instantiationService: IInstantiationService | undefined;
|
||||
private fileInputFactory: IFileInputFactory | undefined;
|
||||
private readonly editorInputFactoryConstructors: Map<string, IConstructorSignature0<IEditorInputFactory>> = new Map();
|
||||
private readonly editorInputFactoryInstances: Map<string, IEditorInputFactory> = new Map();
|
||||
|
||||
start(accessor: ServicesAccessor): void {
|
||||
this.instantiationService = accessor.get(IInstantiationService);
|
||||
const instantiationService = this.instantiationService = accessor.get(IInstantiationService);
|
||||
|
||||
this.editorInputFactoryConstructors.forEach((ctor, key) => {
|
||||
this.createEditorInputFactory(key, ctor);
|
||||
this.createEditorInputFactory(key, ctor, instantiationService);
|
||||
});
|
||||
|
||||
this.editorInputFactoryConstructors.clear();
|
||||
}
|
||||
|
||||
private createEditorInputFactory(editorInputId: string, ctor: IConstructorSignature0<IEditorInputFactory>): void {
|
||||
const instance = this.instantiationService.createInstance(ctor);
|
||||
private createEditorInputFactory(editorInputId: string, ctor: IConstructorSignature0<IEditorInputFactory>, instantiationService: IInstantiationService): void {
|
||||
const instance = instantiationService.createInstance(ctor);
|
||||
this.editorInputFactoryInstances.set(editorInputId, instance);
|
||||
}
|
||||
|
||||
@@ -1120,14 +1138,14 @@ class EditorInputFactoryRegistry implements IEditorInputFactoryRegistry {
|
||||
}
|
||||
|
||||
getFileInputFactory(): IFileInputFactory {
|
||||
return this.fileInputFactory;
|
||||
return assertIsDefined(this.fileInputFactory);
|
||||
}
|
||||
|
||||
registerEditorInputFactory(editorInputId: string, ctor: IConstructorSignature0<IEditorInputFactory>): void {
|
||||
if (!this.instantiationService) {
|
||||
this.editorInputFactoryConstructors.set(editorInputId, ctor);
|
||||
} else {
|
||||
this.createEditorInputFactory(editorInputId, ctor);
|
||||
this.createEditorInputFactory(editorInputId, ctor, this.instantiationService);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,25 +7,27 @@ import { EditorModel } from 'vs/workbench/common/editor';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { IFileService } from 'vs/platform/files/common/files';
|
||||
import { Schemas } from 'vs/base/common/network';
|
||||
import { DataUri } from 'vs/base/common/resources';
|
||||
import { DataUri, basename } from 'vs/base/common/resources';
|
||||
import { MIME_BINARY } from 'vs/base/common/mime';
|
||||
|
||||
/**
|
||||
* An editor model that just represents a resource that can be loaded.
|
||||
*/
|
||||
export class BinaryEditorModel extends EditorModel {
|
||||
private size: number;
|
||||
private size: number | undefined;
|
||||
private etag: string | undefined;
|
||||
private readonly mime: string;
|
||||
|
||||
constructor(
|
||||
private readonly resource: URI,
|
||||
private readonly name: string,
|
||||
private readonly name: string | undefined,
|
||||
@IFileService private readonly fileService: IFileService
|
||||
) {
|
||||
super();
|
||||
|
||||
this.resource = resource;
|
||||
this.name = name;
|
||||
this.mime = MIME_BINARY;
|
||||
|
||||
if (resource.scheme === Schemas.data) {
|
||||
const metadata = DataUri.parseMetaData(resource);
|
||||
@@ -33,7 +35,10 @@ export class BinaryEditorModel extends EditorModel {
|
||||
this.size = Number(metadata.get(DataUri.META_DATA_SIZE));
|
||||
}
|
||||
|
||||
this.mime = metadata.get(DataUri.META_DATA_MIME)!;
|
||||
const metadataMime = metadata.get(DataUri.META_DATA_MIME);
|
||||
if (metadataMime) {
|
||||
this.mime = metadataMime;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +46,7 @@ export class BinaryEditorModel extends EditorModel {
|
||||
* The name of the binary resource.
|
||||
*/
|
||||
getName(): string {
|
||||
return this.name;
|
||||
return this.name || basename(this.resource);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -54,7 +59,7 @@ export class BinaryEditorModel extends EditorModel {
|
||||
/**
|
||||
* The size of the binary resource if known.
|
||||
*/
|
||||
getSize(): number {
|
||||
getSize(): number | undefined {
|
||||
return this.size;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ import { IEditorModel } from 'vs/platform/editor/common/editor';
|
||||
* and the modified version.
|
||||
*/
|
||||
export class DiffEditorModel extends EditorModel {
|
||||
|
||||
protected readonly _originalModel: IEditorModel | null;
|
||||
protected readonly _modifiedModel: IEditorModel | null;
|
||||
|
||||
@@ -58,4 +59,4 @@ export class DiffEditorModel extends EditorModel {
|
||||
|
||||
super.dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ export class EditorGroup extends Disposable {
|
||||
private focusRecentEditorAfterClose: boolean | undefined;
|
||||
|
||||
constructor(
|
||||
labelOrSerializedGroup: ISerializedEditorGroup,
|
||||
labelOrSerializedGroup: ISerializedEditorGroup | undefined,
|
||||
@IInstantiationService private readonly instantiationService: IInstantiationService,
|
||||
@IConfigurationService private readonly configurationService: IConfigurationService
|
||||
) {
|
||||
@@ -156,7 +156,7 @@ export class EditorGroup extends Disposable {
|
||||
|
||||
for (const editor of this.editors) {
|
||||
const editorResource = toResource(editor, { supportSideBySide: SideBySideEditor.MASTER });
|
||||
if (editorResource && editorResource.toString() === resource.toString()) {
|
||||
if (editorResource?.toString() === resource.toString()) {
|
||||
return editor;
|
||||
}
|
||||
}
|
||||
@@ -183,8 +183,8 @@ export class EditorGroup extends Disposable {
|
||||
openEditor(editor: EditorInput, options?: IEditorOpenOptions): void {
|
||||
const index = this.indexOf(editor);
|
||||
|
||||
const makePinned = options && options.pinned;
|
||||
const makeActive = (options && options.active) || !this.activeEditor || (!makePinned && this.matches(this.preview, this.activeEditor));
|
||||
const makePinned = options?.pinned;
|
||||
const makeActive = options?.active || !this.activeEditor || (!makePinned && this.matches(this.preview, this.activeEditor));
|
||||
|
||||
// New editor
|
||||
if (index === -1) {
|
||||
|
||||
@@ -8,6 +8,7 @@ import { URI } from 'vs/base/common/uri';
|
||||
import { IReference } from 'vs/base/common/lifecycle';
|
||||
import { ITextModelService } from 'vs/editor/common/services/resolverService';
|
||||
import { ResourceEditorModel } from 'vs/workbench/common/editor/resourceEditorModel';
|
||||
import { basename } from 'vs/base/common/resources';
|
||||
|
||||
/**
|
||||
* A read-only text editor input whos contents are made of the provided resource that points to an existing
|
||||
@@ -21,7 +22,7 @@ export class ResourceEditorInput extends EditorInput implements IModeSupport {
|
||||
private modelReference: Promise<IReference<ITextEditorModel>> | null = null;
|
||||
|
||||
constructor(
|
||||
private name: string,
|
||||
private name: string | undefined,
|
||||
private description: string | undefined,
|
||||
private readonly resource: URI,
|
||||
private preferredMode: string | undefined,
|
||||
@@ -43,7 +44,7 @@ export class ResourceEditorInput extends EditorInput implements IModeSupport {
|
||||
}
|
||||
|
||||
getName(): string {
|
||||
return this.name;
|
||||
return this.name || basename(this.resource);
|
||||
}
|
||||
|
||||
setName(name: string): void {
|
||||
|
||||
@@ -14,14 +14,17 @@ import { DiffEditorModel } from 'vs/workbench/common/editor/diffEditorModel';
|
||||
*/
|
||||
export class TextDiffEditorModel extends DiffEditorModel {
|
||||
|
||||
protected readonly _originalModel!: BaseTextEditorModel | null;
|
||||
protected readonly _modifiedModel!: BaseTextEditorModel | null;
|
||||
protected readonly _originalModel: BaseTextEditorModel | null;
|
||||
protected readonly _modifiedModel: BaseTextEditorModel | null;
|
||||
|
||||
private _textDiffEditorModel: IDiffEditorModel | null = null;
|
||||
|
||||
constructor(originalModel: BaseTextEditorModel, modifiedModel: BaseTextEditorModel) {
|
||||
super(originalModel, modifiedModel);
|
||||
|
||||
this._originalModel = originalModel;
|
||||
this._modifiedModel = modifiedModel;
|
||||
|
||||
this.updateTextDiffEditorModel();
|
||||
}
|
||||
|
||||
@@ -42,7 +45,7 @@ export class TextDiffEditorModel extends DiffEditorModel {
|
||||
}
|
||||
|
||||
private updateTextDiffEditorModel(): void {
|
||||
if (this.originalModel && this.originalModel.isResolved() && this.modifiedModel && this.modifiedModel.isResolved()) {
|
||||
if (this.originalModel?.isResolved() && this.modifiedModel?.isResolved()) {
|
||||
|
||||
// Create new
|
||||
if (!this._textDiffEditorModel) {
|
||||
|
||||
@@ -35,9 +35,9 @@ export class UntitledEditorInput extends EditorInput implements IEncodingSupport
|
||||
constructor(
|
||||
private readonly resource: URI,
|
||||
private readonly _hasAssociatedFilePath: boolean,
|
||||
private preferredMode: string,
|
||||
private readonly initialValue: string,
|
||||
private preferredEncoding: string,
|
||||
private preferredMode: string | undefined,
|
||||
private readonly initialValue: string | undefined,
|
||||
private preferredEncoding: string | undefined,
|
||||
@IInstantiationService private readonly instantiationService: IInstantiationService,
|
||||
@ITextFileService private readonly textFileService: ITextFileService,
|
||||
@ILabelService private readonly labelService: ILabelService
|
||||
@@ -182,7 +182,7 @@ export class UntitledEditorInput extends EditorInput implements IEncodingSupport
|
||||
return this.getName();
|
||||
}
|
||||
|
||||
getEncoding(): string {
|
||||
getEncoding(): string | undefined {
|
||||
if (this.cachedModel) {
|
||||
return this.cachedModel.getEncoding();
|
||||
}
|
||||
|
||||
@@ -33,14 +33,14 @@ export class UntitledEditorModel extends BaseTextEditorModel implements IEncodin
|
||||
private dirty: boolean = false;
|
||||
private versionId: number = 0;
|
||||
private readonly contentChangeEventScheduler: RunOnceScheduler;
|
||||
private configuredEncoding: string;
|
||||
private configuredEncoding?: string;
|
||||
|
||||
constructor(
|
||||
private readonly preferredMode: string,
|
||||
private readonly preferredMode: string | undefined,
|
||||
private readonly resource: URI,
|
||||
private _hasAssociatedFilePath: boolean,
|
||||
private readonly initialValue: string,
|
||||
private preferredEncoding: string,
|
||||
private readonly initialValue: string | undefined,
|
||||
private preferredEncoding: string | undefined,
|
||||
@IModeService modeService: IModeService,
|
||||
@IModelService modelService: IModelService,
|
||||
@IBackupFileService private readonly backupFileService: IBackupFileService,
|
||||
@@ -87,7 +87,7 @@ export class UntitledEditorModel extends BaseTextEditorModel implements IEncodin
|
||||
return this.preferredMode;
|
||||
}
|
||||
|
||||
getEncoding(): string {
|
||||
getEncoding(): string | undefined {
|
||||
return this.preferredEncoding || this.configuredEncoding;
|
||||
}
|
||||
|
||||
@@ -192,7 +192,7 @@ export class UntitledEditorModel extends BaseTextEditorModel implements IEncodin
|
||||
|
||||
// mark the untitled editor as non-dirty once its content becomes empty and we do
|
||||
// not have an associated path set. we never want dirty indicator in that case.
|
||||
if (!this._hasAssociatedFilePath && this.textEditorModel && this.textEditorModel.getLineCount() === 1 && this.textEditorModel.getLineContent(1) === '') {
|
||||
if (!this._hasAssociatedFilePath && this.textEditorModel.getLineCount() === 1 && this.textEditorModel.getLineContent(1) === '') {
|
||||
this.setDirty(false);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { INotification, INotificationHandle, INotificationActions, INotificationProgress, NoOpNotification, Severity, NotificationMessage, IPromptChoice, IStatusMessageOptions } from 'vs/platform/notification/common/notification';
|
||||
import { INotification, INotificationHandle, INotificationActions, INotificationProgress, NoOpNotification, Severity, NotificationMessage, IPromptChoice, IStatusMessageOptions, NotificationsFilter } from 'vs/platform/notification/common/notification';
|
||||
import { toErrorMessage } from 'vs/base/common/errorMessage';
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
import { Disposable, IDisposable, toDisposable } from 'vs/base/common/lifecycle';
|
||||
@@ -12,6 +12,7 @@ import { Action } from 'vs/base/common/actions';
|
||||
import { isErrorWithActions } from 'vs/base/common/errorsWithActions';
|
||||
import { startsWith } from 'vs/base/common/strings';
|
||||
import { localize } from 'vs/nls';
|
||||
import { find, equals } from 'vs/base/common/arrays';
|
||||
|
||||
export interface INotificationsModel {
|
||||
|
||||
@@ -22,9 +23,12 @@ export interface INotificationsModel {
|
||||
readonly notifications: INotificationViewItem[];
|
||||
|
||||
readonly onDidNotificationChange: Event<INotificationChangeEvent>;
|
||||
readonly onDidFilterChange: Event<NotificationsFilter>;
|
||||
|
||||
addNotification(notification: INotification): INotificationHandle;
|
||||
|
||||
setFilter(filter: NotificationsFilter): void;
|
||||
|
||||
//
|
||||
// Notifications as Status
|
||||
//
|
||||
@@ -123,20 +127,31 @@ export class NotificationHandle implements INotificationHandle {
|
||||
|
||||
export class NotificationsModel extends Disposable implements INotificationsModel {
|
||||
|
||||
private static NO_OP_NOTIFICATION = new NoOpNotification();
|
||||
private static readonly NO_OP_NOTIFICATION = new NoOpNotification();
|
||||
|
||||
private readonly _onDidNotificationChange: Emitter<INotificationChangeEvent> = this._register(new Emitter<INotificationChangeEvent>());
|
||||
private readonly _onDidNotificationChange = this._register(new Emitter<INotificationChangeEvent>());
|
||||
readonly onDidNotificationChange: Event<INotificationChangeEvent> = this._onDidNotificationChange.event;
|
||||
|
||||
private readonly _onDidStatusMessageChange: Emitter<IStatusMessageChangeEvent> = this._register(new Emitter<IStatusMessageChangeEvent>());
|
||||
private readonly _onDidStatusMessageChange = this._register(new Emitter<IStatusMessageChangeEvent>());
|
||||
readonly onDidStatusMessageChange: Event<IStatusMessageChangeEvent> = this._onDidStatusMessageChange.event;
|
||||
|
||||
private readonly _onDidFilterChange = this._register(new Emitter<NotificationsFilter>());
|
||||
readonly onDidFilterChange: Event<NotificationsFilter> = this._onDidFilterChange.event;
|
||||
|
||||
private readonly _notifications: INotificationViewItem[] = [];
|
||||
get notifications(): INotificationViewItem[] { return this._notifications; }
|
||||
|
||||
private _statusMessage: IStatusMessageViewItem | undefined;
|
||||
get statusMessage(): IStatusMessageViewItem | undefined { return this._statusMessage; }
|
||||
|
||||
private filter = NotificationsFilter.OFF;
|
||||
|
||||
setFilter(filter: NotificationsFilter): void {
|
||||
this.filter = filter;
|
||||
|
||||
this._onDidFilterChange.fire(filter);
|
||||
}
|
||||
|
||||
addNotification(notification: INotification): INotificationHandle {
|
||||
const item = this.createViewItem(notification);
|
||||
if (!item) {
|
||||
@@ -169,19 +184,13 @@ export class NotificationsModel extends Disposable implements INotificationsMode
|
||||
}
|
||||
|
||||
private findNotification(item: INotificationViewItem): INotificationViewItem | undefined {
|
||||
for (const notification of this._notifications) {
|
||||
if (notification.equals(item)) {
|
||||
return notification;
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
return find(this._notifications, notification => notification.equals(item));
|
||||
}
|
||||
|
||||
private createViewItem(notification: INotification): INotificationViewItem | null {
|
||||
const item = NotificationViewItem.create(notification);
|
||||
private createViewItem(notification: INotification): INotificationViewItem | undefined {
|
||||
const item = NotificationViewItem.create(notification, this.filter);
|
||||
if (!item) {
|
||||
return null;
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// Item Events
|
||||
@@ -385,11 +394,11 @@ export interface INotificationMessage {
|
||||
|
||||
export class NotificationViewItem extends Disposable implements INotificationViewItem {
|
||||
|
||||
private static MAX_MESSAGE_LENGTH = 1000;
|
||||
private static readonly MAX_MESSAGE_LENGTH = 1000;
|
||||
|
||||
// Example link: "Some message with [link text](http://link.href)."
|
||||
// RegEx: [, anything not ], ], (, http://|https://|command:, no whitespace)
|
||||
private static LINK_REGEX = /\[([^\]]+)\]\(((?:https?:\/\/|command:)[^\)\s]+)(?: "([^"]+)")?\)/gi;
|
||||
private static readonly LINK_REGEX = /\[([^\]]+)\]\(((?:https?:\/\/|command:)[^\)\s]+)(?: "([^"]+)")?\)/gi;
|
||||
|
||||
private _expanded: boolean | undefined;
|
||||
|
||||
@@ -405,9 +414,9 @@ export class NotificationViewItem extends Disposable implements INotificationVie
|
||||
private readonly _onDidLabelChange: Emitter<INotificationViewItemLabelChangeEvent> = this._register(new Emitter<INotificationViewItemLabelChangeEvent>());
|
||||
readonly onDidLabelChange: Event<INotificationViewItemLabelChangeEvent> = this._onDidLabelChange.event;
|
||||
|
||||
static create(notification: INotification): INotificationViewItem | null {
|
||||
static create(notification: INotification, filter: NotificationsFilter = NotificationsFilter.OFF): INotificationViewItem | undefined {
|
||||
if (!notification || !notification.message || isPromiseCanceledError(notification.message)) {
|
||||
return null; // we need a message to show
|
||||
return undefined; // we need a message to show
|
||||
}
|
||||
|
||||
let severity: Severity;
|
||||
@@ -419,7 +428,7 @@ export class NotificationViewItem extends Disposable implements INotificationVie
|
||||
|
||||
const message = NotificationViewItem.parseNotificationMessage(notification.message);
|
||||
if (!message) {
|
||||
return null; // we need a message to show
|
||||
return undefined; // we need a message to show
|
||||
}
|
||||
|
||||
let actions: INotificationActions | undefined;
|
||||
@@ -429,7 +438,7 @@ export class NotificationViewItem extends Disposable implements INotificationVie
|
||||
actions = { primary: notification.message.actions };
|
||||
}
|
||||
|
||||
return new NotificationViewItem(severity, notification.sticky, notification.silent, message, notification.source, actions);
|
||||
return new NotificationViewItem(severity, notification.sticky, notification.silent || filter === NotificationsFilter.SILENT || (filter === NotificationsFilter.ERROR && notification.severity !== Severity.Error), message, notification.source, actions);
|
||||
}
|
||||
|
||||
private static parseNotificationMessage(input: NotificationMessage): INotificationMessage | undefined {
|
||||
@@ -641,17 +650,7 @@ export class NotificationViewItem extends Disposable implements INotificationVie
|
||||
|
||||
const primaryActions = (this._actions && this._actions.primary) || [];
|
||||
const otherPrimaryActions = (other.actions && other.actions.primary) || [];
|
||||
if (primaryActions.length !== otherPrimaryActions.length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (let i = 0; i < primaryActions.length; i++) {
|
||||
if ((primaryActions[i].id + primaryActions[i].label) !== (otherPrimaryActions[i].id + otherPrimaryActions[i].label)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
return equals(primaryActions, otherPrimaryActions, (a, b) => (a.id + a.label) === (b.id + b.label));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -690,9 +689,9 @@ export class ChoiceAction extends Action {
|
||||
|
||||
class StatusMessageViewItem {
|
||||
|
||||
static create(notification: NotificationMessage, options?: IStatusMessageOptions): IStatusMessageViewItem | null {
|
||||
static create(notification: NotificationMessage, options?: IStatusMessageOptions): IStatusMessageViewItem | undefined {
|
||||
if (!notification || isPromiseCanceledError(notification)) {
|
||||
return null; // we need a message to show
|
||||
return undefined; // we need a message to show
|
||||
}
|
||||
|
||||
let message: string | undefined;
|
||||
@@ -703,7 +702,7 @@ class StatusMessageViewItem {
|
||||
}
|
||||
|
||||
if (!message) {
|
||||
return null; // we need a message to show
|
||||
return undefined; // we need a message to show
|
||||
}
|
||||
|
||||
return { message, options };
|
||||
|
||||
@@ -18,13 +18,13 @@ import { withNullAsUndefined } from 'vs/base/common/types';
|
||||
|
||||
export class ResourceContextKey extends Disposable implements IContextKey<URI> {
|
||||
|
||||
static Scheme = new RawContextKey<string>('resourceScheme', undefined);
|
||||
static Filename = new RawContextKey<string>('resourceFilename', undefined);
|
||||
static LangId = new RawContextKey<string>('resourceLangId', undefined);
|
||||
static Resource = new RawContextKey<URI>('resource', undefined);
|
||||
static Extension = new RawContextKey<string>('resourceExtname', undefined);
|
||||
static HasResource = new RawContextKey<boolean>('resourceSet', false);
|
||||
static IsFileSystemResource = new RawContextKey<boolean>('isFileSystemResource', false);
|
||||
static readonly Scheme = new RawContextKey<string>('resourceScheme', undefined);
|
||||
static readonly Filename = new RawContextKey<string>('resourceFilename', undefined);
|
||||
static readonly LangId = new RawContextKey<string>('resourceLangId', undefined);
|
||||
static readonly Resource = new RawContextKey<URI>('resource', undefined);
|
||||
static readonly Extension = new RawContextKey<string>('resourceExtname', undefined);
|
||||
static readonly HasResource = new RawContextKey<boolean>('resourceSet', false);
|
||||
static readonly IsFileSystemResource = new RawContextKey<boolean>('isFileSystemResource', false);
|
||||
|
||||
private readonly _resourceKey: IContextKey<URI | null>;
|
||||
private readonly _schemeKey: IContextKey<string | null>;
|
||||
@@ -180,24 +180,24 @@ export class ResourceGlobMatcher extends Disposable {
|
||||
matches(resource: URI): boolean {
|
||||
const folder = this.contextService.getWorkspaceFolder(resource);
|
||||
|
||||
let expressionForRoot: ParsedExpression;
|
||||
let expressionForRoot: ParsedExpression | undefined;
|
||||
if (folder && this.mapRootToParsedExpression.has(folder.uri.toString())) {
|
||||
expressionForRoot = this.mapRootToParsedExpression.get(folder.uri.toString())!;
|
||||
expressionForRoot = this.mapRootToParsedExpression.get(folder.uri.toString());
|
||||
} else {
|
||||
expressionForRoot = this.mapRootToParsedExpression.get(ResourceGlobMatcher.NO_ROOT)!;
|
||||
expressionForRoot = this.mapRootToParsedExpression.get(ResourceGlobMatcher.NO_ROOT);
|
||||
}
|
||||
|
||||
// If the resource if from a workspace, convert its absolute path to a relative
|
||||
// path so that glob patterns have a higher probability to match. For example
|
||||
// a glob pattern of "src/**" will not match on an absolute path "/folder/src/file.txt"
|
||||
// but can match on "src/file.txt"
|
||||
let resourcePathToMatch: string;
|
||||
let resourcePathToMatch: string | undefined;
|
||||
if (folder) {
|
||||
resourcePathToMatch = relativePath(folder.uri, resource)!; // always uses forward slashes
|
||||
resourcePathToMatch = relativePath(folder.uri, resource); // always uses forward slashes
|
||||
} else {
|
||||
resourcePathToMatch = resource.fsPath; // TODO@isidor: support non-file URIs
|
||||
}
|
||||
|
||||
return !!expressionForRoot(resourcePathToMatch);
|
||||
return !!expressionForRoot && typeof resourcePathToMatch === 'string' && !!expressionForRoot(resourcePathToMatch);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as nls from 'vs/nls';
|
||||
import { registerColor, editorBackground, contrastBorder, transparent, editorWidgetBackground, textLinkForeground, lighten, darken, focusBorder, activeContrastBorder, editorWidgetForeground } from 'vs/platform/theme/common/colorRegistry';
|
||||
import { registerColor, editorBackground, contrastBorder, transparent, editorWidgetBackground, textLinkForeground, lighten, darken, focusBorder, activeContrastBorder, editorWidgetForeground, editorErrorForeground, editorWarningForeground, editorInfoForeground } from 'vs/platform/theme/common/colorRegistry';
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import { IThemeService, ITheme } from 'vs/platform/theme/common/themeService';
|
||||
import { Color } from 'vs/base/common/color';
|
||||
@@ -235,8 +235,8 @@ export const PANEL_INACTIVE_TITLE_FOREGROUND = registerColor('panelTitle.inactiv
|
||||
}, nls.localize('panelInactiveTitleForeground', "Title color for the inactive panel. Panels are shown below the editor area and contain views like output and integrated terminal."));
|
||||
|
||||
export const PANEL_ACTIVE_TITLE_BORDER = registerColor('panelTitle.activeBorder', {
|
||||
dark: PANEL_BORDER,
|
||||
light: PANEL_BORDER,
|
||||
dark: PANEL_ACTIVE_TITLE_FOREGROUND,
|
||||
light: PANEL_ACTIVE_TITLE_FOREGROUND,
|
||||
hc: contrastBorder
|
||||
}, nls.localize('panelActiveTitleBorder', "Border color for the active panel title. Panels are shown below the editor area and contain views like output and integrated terminal."));
|
||||
|
||||
@@ -335,8 +335,8 @@ export const ACTIVITY_BAR_FOREGROUND = registerColor('activityBar.foreground', {
|
||||
}, nls.localize('activityBarForeground', "Activity bar item foreground color when it is active. The activity bar is showing on the far left or right and allows to switch between views of the side bar."));
|
||||
|
||||
export const ACTIVITY_BAR_INACTIVE_FOREGROUND = registerColor('activityBar.inactiveForeground', {
|
||||
dark: transparent(ACTIVITY_BAR_FOREGROUND, 0.6),
|
||||
light: transparent(ACTIVITY_BAR_FOREGROUND, 0.6),
|
||||
dark: transparent(ACTIVITY_BAR_FOREGROUND, 0.4),
|
||||
light: transparent(ACTIVITY_BAR_FOREGROUND, 0.4),
|
||||
hc: Color.white
|
||||
}, nls.localize('activityBarInActiveForeground', "Activity bar item foreground color when it is inactive. The activity bar is showing on the far left or right and allows to switch between views of the side bar."));
|
||||
|
||||
@@ -346,6 +346,18 @@ export const ACTIVITY_BAR_BORDER = registerColor('activityBar.border', {
|
||||
hc: contrastBorder
|
||||
}, nls.localize('activityBarBorder', "Activity bar border color separating to the side bar. The activity bar is showing on the far left or right and allows to switch between views of the side bar."));
|
||||
|
||||
export const ACTIVITY_BAR_ACTIVE_BORDER = registerColor('activityBar.activeBorder', {
|
||||
dark: ACTIVITY_BAR_FOREGROUND,
|
||||
light: ACTIVITY_BAR_FOREGROUND,
|
||||
hc: null
|
||||
}, nls.localize('activityBarActiveBorder', "Activity bar border color for the active item. The activity bar is showing on the far left or right and allows to switch between views of the side bar."));
|
||||
|
||||
export const ACTIVITY_BAR_ACTIVE_BACKGROUND = registerColor('activityBar.activeBackground', {
|
||||
dark: null,
|
||||
light: null,
|
||||
hc: null
|
||||
}, nls.localize('activityBarActiveBackground', "Activity bar background color for the active item. The activity bar is showing on the far left or right and allows to switch between views of the side bar."));
|
||||
|
||||
export const ACTIVITY_BAR_DRAG_AND_DROP_BACKGROUND = registerColor('activityBar.dropBackground', {
|
||||
dark: Color.white.transparent(0.12),
|
||||
light: Color.white.transparent(0.12),
|
||||
@@ -560,21 +572,21 @@ export const NOTIFICATIONS_BORDER = registerColor('notifications.border', {
|
||||
}, nls.localize('notificationsBorder', "Notifications border color separating from other notifications in the notifications center. Notifications slide in from the bottom right of the window."));
|
||||
|
||||
export const NOTIFICATIONS_ERROR_ICON_FOREGROUND = registerColor('notificationsErrorIcon.foreground', {
|
||||
dark: '#F48771',
|
||||
light: '#A1260D',
|
||||
hc: '#F48771'
|
||||
dark: editorErrorForeground,
|
||||
light: editorErrorForeground,
|
||||
hc: editorErrorForeground
|
||||
}, nls.localize('notificationsErrorIconForeground', "The color used for the notification error icon."));
|
||||
|
||||
export const NOTIFICATIONS_WARNING_ICON_FOREGROUND = registerColor('notificationsWarningIcon.foreground', {
|
||||
dark: '#FFCC00',
|
||||
light: '#DDB100',
|
||||
hc: '#FFCC00'
|
||||
dark: editorWarningForeground,
|
||||
light: editorWarningForeground,
|
||||
hc: editorWarningForeground
|
||||
}, nls.localize('notificationsWarningIconForeground', "The color used for the notification warning icon."));
|
||||
|
||||
export const NOTIFICATIONS_INFO_ICON_FOREGROUND = registerColor('notificationsInfoIcon.foreground', {
|
||||
dark: '#75BEFF',
|
||||
light: '#007ACC',
|
||||
hc: '#75BEFF'
|
||||
dark: editorInfoForeground,
|
||||
light: editorInfoForeground,
|
||||
hc: editorInfoForeground
|
||||
}, nls.localize('notificationsInfoIconForeground', "The color used for the notification info icon."));
|
||||
|
||||
/**
|
||||
|
||||
@@ -15,5 +15,5 @@ export interface IViewlet extends IComposite {
|
||||
/**
|
||||
* Returns the minimal width needed to avoid any content horizontal truncation
|
||||
*/
|
||||
getOptimalWidth(): number | null;
|
||||
getOptimalWidth(): number | undefined;
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ import { Command } from 'vs/editor/common/modes';
|
||||
import { UriComponents } from 'vs/base/common/uri';
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
import { ContextKeyExpr, RawContextKey } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { ITreeViewDataProvider } from 'vs/workbench/common/views';
|
||||
import { localize } from 'vs/nls';
|
||||
import { IViewlet } from 'vs/workbench/common/viewlet';
|
||||
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
|
||||
|
||||
Reference in New Issue
Block a user