Revert "Revert "Merge from vscode ada4bddb8edc69eea6ebaaa0e88c5f903cbd43d8 (#5529)" (#5553)" (#5562)

This reverts commit c9a4f8f664.
This commit is contained in:
Anthony Dresser
2019-05-21 14:19:32 -07:00
committed by GitHub
parent 7670104e4d
commit 81ae86ff79
325 changed files with 4497 additions and 3328 deletions

View File

@@ -5,7 +5,7 @@
import { Event, Emitter } from 'vs/base/common/event';
import { assign } from 'vs/base/common/objects';
import { isUndefinedOrNull, withUndefinedAsNull } from 'vs/base/common/types';
import { isUndefinedOrNull } 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';
@@ -144,7 +144,7 @@ export interface IEditorControl extends ICompositeControl { }
export interface IFileInputFactory {
createFileInput(resource: URI, encoding: string | undefined, instantiationService: IInstantiationService): IFileEditorInput;
createFileInput(resource: URI, encoding: string | undefined, mode: string | undefined, instantiationService: IInstantiationService): IFileEditorInput;
isFileInput(obj: any): obj is IFileEditorInput;
}
@@ -209,7 +209,7 @@ export interface IUntitledResourceInput extends IBaseResourceInput {
/**
* Optional language of the untitled resource.
*/
language?: string;
mode?: string;
/**
* Optional contents of the untitled resource.
@@ -516,19 +516,35 @@ export interface IEncodingSupport {
setEncoding(encoding: string, mode: EncodingMode): void;
}
export interface IModeSupport {
/**
* Sets the language mode of the input.
*/
setMode(mode: string): void;
}
/**
* This is a tagging interface to declare an editor input being capable of dealing with files. It is only used in the editor registry
* to register this kind of input to the platform.
*/
export interface IFileEditorInput extends IEditorInput, IEncodingSupport {
export interface IFileEditorInput extends IEditorInput, IEncodingSupport, IModeSupport {
/**
* Gets the resource this editor is about.
*/
getResource(): URI;
/**
* Sets the preferred encodingt to use for this input.
* Sets the preferred encoding to use for this input.
*/
setPreferredEncoding(encoding: string): void;
/**
* Sets the preferred language mode to use for this input.
*/
setPreferredMode(mode: string): void;
/**
* Forces this file input to open as binary instead of text.
*/
@@ -577,7 +593,7 @@ export class SideBySideEditorInput extends EditorInput {
return this.master.revert();
}
getTelemetryDescriptor(): object {
getTelemetryDescriptor(): { [key: string]: unknown } {
const descriptor = this.master.getTelemetryDescriptor();
return assign(descriptor, super.getTelemetryDescriptor());
@@ -631,8 +647,7 @@ export class SideBySideEditorInput extends EditorInput {
return false;
}
const otherDiffInput = <SideBySideEditorInput>otherInput;
return this.details.matches(otherDiffInput.details) && this.master.matches(otherDiffInput.master);
return this.details.matches(otherInput.details) && this.master.matches(otherInput.master);
}
return false;
@@ -998,9 +1013,9 @@ export interface IResourceOptions {
filterByScheme?: string | string[];
}
export function toResource(editor: IEditorInput | null | undefined, options?: IResourceOptions): URI | null {
export function toResource(editor: IEditorInput | undefined, options?: IResourceOptions): URI | undefined {
if (!editor) {
return null;
return undefined;
}
if (options && options.supportSideBySide && editor instanceof SideBySideEditorInput) {
@@ -1009,7 +1024,7 @@ export function toResource(editor: IEditorInput | null | undefined, options?: IR
const resource = editor.getResource();
if (!resource || !options || !options.filterByScheme) {
return withUndefinedAsNull(resource);
return resource;
}
if (Array.isArray(options.filterByScheme) && options.filterByScheme.some(scheme => resource.scheme === scheme)) {
@@ -1020,7 +1035,7 @@ export function toResource(editor: IEditorInput | null | undefined, options?: IR
return resource;
}
return null;
return undefined;
}
export const enum CloseDirection {