mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-07 17:23:56 -05:00
Merge from vscode 2cd495805cf99b31b6926f08ff4348124b2cf73d
This commit is contained in:
committed by
AzureDataStudio
parent
a8a7559229
commit
1388493cc1
@@ -649,10 +649,16 @@ export interface IModeSupport {
|
||||
export interface IFileEditorInput extends IEditorInput, IEncodingSupport, IModeSupport {
|
||||
|
||||
/**
|
||||
* Gets the resource this editor is about.
|
||||
* Gets the resource this file input is about.
|
||||
*/
|
||||
readonly resource: URI;
|
||||
|
||||
/**
|
||||
* Gets the label of the editor. In most cases this will
|
||||
* be identical to the resource.
|
||||
*/
|
||||
readonly label: URI;
|
||||
|
||||
/**
|
||||
* Sets the preferred label to use for this file input.
|
||||
*/
|
||||
@@ -680,7 +686,7 @@ export interface IFileEditorInput extends IEditorInput, IEncodingSupport, IModeS
|
||||
}
|
||||
|
||||
/**
|
||||
* Side by side editor inputs that have a master and details side.
|
||||
* Side by side editor inputs that have a primary and secondary side.
|
||||
*/
|
||||
export class SideBySideEditorInput extends EditorInput {
|
||||
|
||||
@@ -689,8 +695,8 @@ export class SideBySideEditorInput extends EditorInput {
|
||||
constructor(
|
||||
protected readonly name: string | undefined,
|
||||
private readonly description: string | undefined,
|
||||
private readonly _details: EditorInput,
|
||||
private readonly _master: EditorInput
|
||||
private readonly _secondary: EditorInput,
|
||||
private readonly _primary: EditorInput
|
||||
) {
|
||||
super();
|
||||
|
||||
@@ -699,36 +705,36 @@ export class SideBySideEditorInput extends EditorInput {
|
||||
|
||||
private registerListeners(): void {
|
||||
|
||||
// When the details or master input gets disposed, dispose this diff editor input
|
||||
const onceDetailsDisposed = Event.once(this.details.onDispose);
|
||||
this._register(onceDetailsDisposed(() => {
|
||||
// When the primary or secondary input gets disposed, dispose this diff editor input
|
||||
const onceSecondaryDisposed = Event.once(this.secondary.onDispose);
|
||||
this._register(onceSecondaryDisposed(() => {
|
||||
if (!this.isDisposed()) {
|
||||
this.dispose();
|
||||
}
|
||||
}));
|
||||
|
||||
const onceMasterDisposed = Event.once(this.master.onDispose);
|
||||
this._register(onceMasterDisposed(() => {
|
||||
const oncePrimaryDisposed = Event.once(this.primary.onDispose);
|
||||
this._register(oncePrimaryDisposed(() => {
|
||||
if (!this.isDisposed()) {
|
||||
this.dispose();
|
||||
}
|
||||
}));
|
||||
|
||||
// Reemit some events from the master side to the outside
|
||||
this._register(this.master.onDidChangeDirty(() => this._onDidChangeDirty.fire()));
|
||||
this._register(this.master.onDidChangeLabel(() => this._onDidChangeLabel.fire()));
|
||||
// Reemit some events from the primary side to the outside
|
||||
this._register(this.primary.onDidChangeDirty(() => this._onDidChangeDirty.fire()));
|
||||
this._register(this.primary.onDidChangeLabel(() => this._onDidChangeLabel.fire()));
|
||||
}
|
||||
|
||||
get resource(): URI | undefined {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
get master(): EditorInput {
|
||||
return this._master;
|
||||
get primary(): EditorInput {
|
||||
return this._primary;
|
||||
}
|
||||
|
||||
get details(): EditorInput {
|
||||
return this._details;
|
||||
get secondary(): EditorInput {
|
||||
return this._secondary;
|
||||
}
|
||||
|
||||
getTypeId(): string {
|
||||
@@ -737,7 +743,7 @@ export class SideBySideEditorInput extends EditorInput {
|
||||
|
||||
getName(): string {
|
||||
if (!this.name) {
|
||||
return localize('sideBySideLabels', "{0} - {1}", this._details.getName(), this._master.getName());
|
||||
return localize('sideBySideLabels', "{0} - {1}", this._secondary.getName(), this._primary.getName());
|
||||
}
|
||||
|
||||
return this.name;
|
||||
@@ -748,50 +754,46 @@ export class SideBySideEditorInput extends EditorInput {
|
||||
}
|
||||
|
||||
isReadonly(): boolean {
|
||||
return this.master.isReadonly();
|
||||
return this.primary.isReadonly();
|
||||
}
|
||||
|
||||
isUntitled(): boolean {
|
||||
return this.master.isUntitled();
|
||||
return this.primary.isUntitled();
|
||||
}
|
||||
|
||||
isDirty(): boolean {
|
||||
return this.master.isDirty();
|
||||
return this.primary.isDirty();
|
||||
}
|
||||
|
||||
isSaving(): boolean {
|
||||
return this.master.isSaving();
|
||||
return this.primary.isSaving();
|
||||
}
|
||||
|
||||
save(group: GroupIdentifier, options?: ISaveOptions): Promise<IEditorInput | undefined> {
|
||||
return this.master.save(group, options);
|
||||
return this.primary.save(group, options);
|
||||
}
|
||||
|
||||
saveAs(group: GroupIdentifier, options?: ISaveOptions): Promise<IEditorInput | undefined> {
|
||||
return this.master.saveAs(group, options);
|
||||
return this.primary.saveAs(group, options);
|
||||
}
|
||||
|
||||
revert(group: GroupIdentifier, options?: IRevertOptions): Promise<void> {
|
||||
return this.master.revert(group, options);
|
||||
return this.primary.revert(group, options);
|
||||
}
|
||||
|
||||
getTelemetryDescriptor(): { [key: string]: unknown } {
|
||||
const descriptor = this.master.getTelemetryDescriptor();
|
||||
const descriptor = this.primary.getTelemetryDescriptor();
|
||||
|
||||
return Object.assign(descriptor, super.getTelemetryDescriptor());
|
||||
}
|
||||
|
||||
matches(otherInput: unknown): boolean {
|
||||
if (super.matches(otherInput) === true) {
|
||||
if (otherInput === this) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (otherInput) {
|
||||
if (!(otherInput instanceof SideBySideEditorInput)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return this.details.matches(otherInput.details) && this.master.matches(otherInput.master);
|
||||
if (otherInput instanceof SideBySideEditorInput) {
|
||||
return this.primary.matches(otherInput.primary) && this.secondary.matches(otherInput.secondary);
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -1210,8 +1212,8 @@ export interface IEditorPartOptionsChangeEvent {
|
||||
}
|
||||
|
||||
export enum SideBySideEditor {
|
||||
MASTER = 1,
|
||||
DETAILS = 2,
|
||||
PRIMARY = 1,
|
||||
SECONDARY = 2,
|
||||
BOTH = 3
|
||||
}
|
||||
|
||||
@@ -1221,9 +1223,9 @@ export interface IResourceOptions {
|
||||
}
|
||||
|
||||
export function toResource(editor: IEditorInput | undefined | null): URI | undefined;
|
||||
export function toResource(editor: IEditorInput | undefined | null, options: IResourceOptions & { supportSideBySide?: SideBySideEditor.MASTER | SideBySideEditor.DETAILS }): URI | undefined;
|
||||
export function toResource(editor: IEditorInput | undefined | null, options: IResourceOptions & { supportSideBySide: SideBySideEditor.BOTH }): URI | { master?: URI, detail?: URI } | undefined;
|
||||
export function toResource(editor: IEditorInput | undefined | null, options?: IResourceOptions): URI | { master?: URI, detail?: URI } | undefined {
|
||||
export function toResource(editor: IEditorInput | undefined | null, options: IResourceOptions & { supportSideBySide?: SideBySideEditor.PRIMARY | SideBySideEditor.SECONDARY }): URI | undefined;
|
||||
export function toResource(editor: IEditorInput | undefined | null, options: IResourceOptions & { supportSideBySide: SideBySideEditor.BOTH }): URI | { primary?: URI, secondary?: URI } | undefined;
|
||||
export function toResource(editor: IEditorInput | undefined | null, options?: IResourceOptions): URI | { primary?: URI, secondary?: URI } | undefined {
|
||||
if (!editor) {
|
||||
return undefined;
|
||||
}
|
||||
@@ -1231,12 +1233,12 @@ export function toResource(editor: IEditorInput | undefined | null, options?: IR
|
||||
if (options?.supportSideBySide && editor instanceof SideBySideEditorInput) {
|
||||
if (options?.supportSideBySide === SideBySideEditor.BOTH) {
|
||||
return {
|
||||
master: toResource(editor.master, { filterByScheme: options.filterByScheme }),
|
||||
detail: toResource(editor.details, { filterByScheme: options.filterByScheme })
|
||||
primary: toResource(editor.primary, { filterByScheme: options.filterByScheme }),
|
||||
secondary: toResource(editor.secondary, { filterByScheme: options.filterByScheme })
|
||||
};
|
||||
}
|
||||
|
||||
editor = options.supportSideBySide === SideBySideEditor.MASTER ? editor.master : editor.details;
|
||||
editor = options.supportSideBySide === SideBySideEditor.PRIMARY ? editor.primary : editor.secondary;
|
||||
}
|
||||
|
||||
const resource = editor.resource;
|
||||
|
||||
@@ -697,7 +697,7 @@ export class EditorGroup extends Disposable {
|
||||
}
|
||||
|
||||
if (options?.supportSideBySide && editor instanceof SideBySideEditorInput) {
|
||||
if (this.matches(editor.master, candidate, options?.strictEquals) || this.matches(editor.details, candidate, options?.strictEquals)) {
|
||||
if (this.matches(editor.primary, candidate, options?.strictEquals) || this.matches(editor.secondary, candidate, options?.strictEquals)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ import { IFileService } from 'vs/platform/files/common/files';
|
||||
import { ILabelService } from 'vs/platform/label/common/label';
|
||||
import { IFilesConfigurationService } from 'vs/workbench/services/filesConfiguration/common/filesConfigurationService';
|
||||
import { AbstractTextResourceEditorInput } from 'vs/workbench/common/editor/textResourceEditorInput';
|
||||
import { extUri } from 'vs/base/common/resources';
|
||||
|
||||
/**
|
||||
* A read-only text editor input whos contents are made of the provided resource that points to an existing
|
||||
@@ -109,13 +110,12 @@ export class ResourceEditorInput extends AbstractTextResourceEditorInput impleme
|
||||
}
|
||||
|
||||
matches(otherInput: unknown): boolean {
|
||||
if (super.matches(otherInput) === true) {
|
||||
if (otherInput === this) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Compare by properties
|
||||
if (otherInput instanceof ResourceEditorInput) {
|
||||
return otherInput.resource.toString() === this.resource.toString();
|
||||
return extUri.isEqual(otherInput.resource, this.resource);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@@ -22,7 +22,8 @@ export abstract class AbstractTextResourceEditorInput extends EditorInput {
|
||||
|
||||
private static readonly MEMOIZER = createMemoizer();
|
||||
|
||||
private label: URI;
|
||||
private _label: URI;
|
||||
get label(): URI { return this._label; }
|
||||
|
||||
constructor(
|
||||
public readonly resource: URI,
|
||||
@@ -36,7 +37,7 @@ export abstract class AbstractTextResourceEditorInput extends EditorInput {
|
||||
) {
|
||||
super();
|
||||
|
||||
this.label = preferredLabel || resource;
|
||||
this._label = preferredLabel || resource;
|
||||
|
||||
this.registerListeners();
|
||||
}
|
||||
@@ -50,7 +51,7 @@ export abstract class AbstractTextResourceEditorInput extends EditorInput {
|
||||
}
|
||||
|
||||
private onLabelEvent(scheme: string): void {
|
||||
if (scheme === this.label.scheme) {
|
||||
if (scheme === this._label.scheme) {
|
||||
this.updateLabel();
|
||||
}
|
||||
}
|
||||
@@ -65,15 +66,15 @@ export abstract class AbstractTextResourceEditorInput extends EditorInput {
|
||||
}
|
||||
|
||||
setLabel(label: URI): void {
|
||||
if (!extUri.isEqual(label, this.label)) {
|
||||
this.label = label;
|
||||
if (!extUri.isEqual(label, this._label)) {
|
||||
this._label = label;
|
||||
|
||||
this.updateLabel();
|
||||
}
|
||||
}
|
||||
|
||||
getLabel(): URI {
|
||||
return this.label;
|
||||
return this._label;
|
||||
}
|
||||
|
||||
getName(): string {
|
||||
@@ -82,7 +83,7 @@ export abstract class AbstractTextResourceEditorInput extends EditorInput {
|
||||
|
||||
@AbstractTextResourceEditorInput.MEMOIZER
|
||||
private get basename(): string {
|
||||
return this.labelService.getUriBasenameLabel(this.label);
|
||||
return this.labelService.getUriBasenameLabel(this._label);
|
||||
}
|
||||
|
||||
getDescription(verbosity: Verbosity = Verbosity.MEDIUM): string | undefined {
|
||||
@@ -99,17 +100,17 @@ export abstract class AbstractTextResourceEditorInput extends EditorInput {
|
||||
|
||||
@AbstractTextResourceEditorInput.MEMOIZER
|
||||
private get shortDescription(): string {
|
||||
return this.labelService.getUriBasenameLabel(dirname(this.label));
|
||||
return this.labelService.getUriBasenameLabel(dirname(this._label));
|
||||
}
|
||||
|
||||
@AbstractTextResourceEditorInput.MEMOIZER
|
||||
private get mediumDescription(): string {
|
||||
return this.labelService.getUriLabel(dirname(this.label), { relative: true });
|
||||
return this.labelService.getUriLabel(dirname(this._label), { relative: true });
|
||||
}
|
||||
|
||||
@AbstractTextResourceEditorInput.MEMOIZER
|
||||
private get longDescription(): string {
|
||||
return this.labelService.getUriLabel(dirname(this.label));
|
||||
return this.labelService.getUriLabel(dirname(this._label));
|
||||
}
|
||||
|
||||
@AbstractTextResourceEditorInput.MEMOIZER
|
||||
@@ -119,12 +120,12 @@ export abstract class AbstractTextResourceEditorInput extends EditorInput {
|
||||
|
||||
@AbstractTextResourceEditorInput.MEMOIZER
|
||||
private get mediumTitle(): string {
|
||||
return this.labelService.getUriLabel(this.label, { relative: true });
|
||||
return this.labelService.getUriLabel(this._label, { relative: true });
|
||||
}
|
||||
|
||||
@AbstractTextResourceEditorInput.MEMOIZER
|
||||
private get longTitle(): string {
|
||||
return this.labelService.getUriLabel(this.label);
|
||||
return this.labelService.getUriLabel(this._label);
|
||||
}
|
||||
|
||||
getTitle(verbosity: Verbosity): string {
|
||||
@@ -163,7 +164,7 @@ export abstract class AbstractTextResourceEditorInput extends EditorInput {
|
||||
return false;
|
||||
}
|
||||
|
||||
async save(group: GroupIdentifier, options?: ITextFileSaveOptions): Promise<IEditorInput | undefined> {
|
||||
save(group: GroupIdentifier, options?: ITextFileSaveOptions): Promise<IEditorInput | undefined> {
|
||||
return this.doSave(group, options, false);
|
||||
}
|
||||
|
||||
@@ -185,7 +186,12 @@ export abstract class AbstractTextResourceEditorInput extends EditorInput {
|
||||
return undefined; // save cancelled
|
||||
}
|
||||
|
||||
return this.editorService.createEditorInput({ resource: target });
|
||||
// If the target is a different resource, return with a new editor input
|
||||
if (!extUri.isEqual(target, this.resource)) {
|
||||
return this.editorService.createEditorInput({ resource: target });
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
async revert(group: GroupIdentifier, options?: IRevertOptions): Promise<void> {
|
||||
|
||||
@@ -23,6 +23,7 @@ import { IProgressIndicator } from 'vs/platform/progress/common/progress';
|
||||
import Severity from 'vs/base/common/severity';
|
||||
import { IPaneComposite } from 'vs/workbench/common/panecomposite';
|
||||
import { IAccessibilityInformation } from 'vs/platform/accessibility/common/accessibility';
|
||||
import { IMarkdownString } from 'vs/base/common/htmlContent';
|
||||
|
||||
export const TEST_VIEW_CONTAINER_ID = 'workbench.view.extension.test';
|
||||
|
||||
@@ -580,6 +581,7 @@ export interface ITreeView extends IDisposable {
|
||||
|
||||
setFocus(item: ITreeItem): void;
|
||||
|
||||
show(container: any): void;
|
||||
}
|
||||
|
||||
export interface IRevealOptions {
|
||||
@@ -635,7 +637,7 @@ export interface ITreeItem {
|
||||
|
||||
resourceUri?: UriComponents;
|
||||
|
||||
tooltip?: string;
|
||||
tooltip?: string | IMarkdownString;
|
||||
|
||||
contextValue?: string;
|
||||
|
||||
@@ -646,6 +648,56 @@ export interface ITreeItem {
|
||||
accessibilityInformation?: IAccessibilityInformation;
|
||||
}
|
||||
|
||||
export class ResolvableTreeItem implements ITreeItem {
|
||||
handle: string;
|
||||
parentHandle?: string;
|
||||
collapsibleState: TreeItemCollapsibleState;
|
||||
label?: ITreeItemLabel;
|
||||
description?: string | boolean;
|
||||
icon?: UriComponents;
|
||||
iconDark?: UriComponents;
|
||||
themeIcon?: ThemeIcon;
|
||||
resourceUri?: UriComponents;
|
||||
tooltip?: string | IMarkdownString;
|
||||
contextValue?: string;
|
||||
command?: Command;
|
||||
children?: ITreeItem[];
|
||||
accessibilityInformation?: IAccessibilityInformation;
|
||||
resolve: () => Promise<void>;
|
||||
private resolved: boolean = false;
|
||||
private _hasResolve: boolean = false;
|
||||
constructor(treeItem: ITreeItem, resolve?: (() => Promise<ITreeItem | undefined>)) {
|
||||
this.handle = treeItem.handle;
|
||||
this.parentHandle = treeItem.parentHandle;
|
||||
this.collapsibleState = treeItem.collapsibleState;
|
||||
this.label = treeItem.label;
|
||||
this.description = treeItem.description;
|
||||
this.icon = treeItem.icon;
|
||||
this.iconDark = treeItem.iconDark;
|
||||
this.themeIcon = treeItem.themeIcon;
|
||||
this.resourceUri = treeItem.resourceUri;
|
||||
this.tooltip = treeItem.tooltip;
|
||||
this.contextValue = treeItem.contextValue;
|
||||
this.command = treeItem.command;
|
||||
this.children = treeItem.children;
|
||||
this.accessibilityInformation = treeItem.accessibilityInformation;
|
||||
this._hasResolve = !!resolve;
|
||||
this.resolve = async () => {
|
||||
if (resolve && !this.resolved) {
|
||||
const resolvedItem = await resolve();
|
||||
if (resolvedItem) {
|
||||
// Resolvable elements. Currently only tooltip.
|
||||
this.tooltip = resolvedItem.tooltip;
|
||||
}
|
||||
}
|
||||
this.resolved = true;
|
||||
};
|
||||
}
|
||||
get hasResolve(): boolean {
|
||||
return this._hasResolve;
|
||||
}
|
||||
}
|
||||
|
||||
export interface ITreeViewDataProvider {
|
||||
readonly isTreeEmpty?: boolean;
|
||||
onDidChangeEmpty?: Event<void>;
|
||||
|
||||
Reference in New Issue
Block a user