Merge from vscode 591842cc4b71958c81947b254924a215fe3edcbd (#4886)

This commit is contained in:
Karl Burtram
2019-04-05 14:14:26 -07:00
committed by GitHub
parent 657adafb7d
commit 0532346f4f
117 changed files with 1691 additions and 1191 deletions

View File

@@ -4,8 +4,8 @@
*--------------------------------------------------------------------------------------------*/
import { Event, Emitter } from 'vs/base/common/event';
import * as objects from 'vs/base/common/objects';
import * as types from 'vs/base/common/types';
import { assign } from 'vs/base/common/objects';
import { isUndefinedOrNull, withUndefinedAsNull } 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';
@@ -14,7 +14,6 @@ import { IInstantiationService, IConstructorSignature0, ServicesAccessor } from
import { RawContextKey, ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
import { Registry } from 'vs/platform/registry/common/platform';
import { ITextModel } from 'vs/editor/common/model';
import { Schemas } from 'vs/base/common/network';
import { IEditorGroup } from 'vs/workbench/services/editor/common/editorGroupsService';
import { ICompositeControl } from 'vs/workbench/common/composite';
import { ActionRunner, IAction } from 'vs/base/common/actions';
@@ -582,7 +581,7 @@ export class SideBySideEditorInput extends EditorInput {
getTelemetryDescriptor(): object {
const descriptor = this.master.getTelemetryDescriptor();
return objects.assign(descriptor, super.getTelemetryDescriptor());
return assign(descriptor, super.getTelemetryDescriptor());
}
private registerListeners(): void {
@@ -838,7 +837,7 @@ export class TextEditorOptions extends EditorOptions {
* Returns if this options object has objects defined for the editor.
*/
hasOptionsDefined(): boolean {
return !!this.editorViewState || (!types.isUndefinedOrNull(this.startLineNumber) && !types.isUndefinedOrNull(this.startColumn));
return !!this.editorViewState || (!isUndefinedOrNull(this.startLineNumber) && !isUndefinedOrNull(this.startColumn));
}
/**
@@ -886,10 +885,10 @@ export class TextEditorOptions extends EditorOptions {
}
// Otherwise check for selection
else if (!types.isUndefinedOrNull(this.startLineNumber) && !types.isUndefinedOrNull(this.startColumn)) {
else if (!isUndefinedOrNull(this.startLineNumber) && !isUndefinedOrNull(this.startColumn)) {
// Select
if (!types.isUndefinedOrNull(this.endLineNumber) && !types.isUndefinedOrNull(this.endColumn)) {
if (!isUndefinedOrNull(this.endLineNumber) && !isUndefinedOrNull(this.endColumn)) {
const range = {
startLineNumber: this.startLineNumber,
startColumn: this.startColumn,
@@ -990,9 +989,14 @@ export interface IEditorPartOptions extends IEditorPartConfiguration {
iconTheme?: string;
}
export enum SideBySideEditor {
MASTER = 1,
DETAILS = 2
}
export interface IResourceOptions {
supportSideBySide?: boolean;
filter?: string | string[];
supportSideBySide?: SideBySideEditor;
filterByScheme?: string | string[];
}
export function toResource(editor: IEditorInput | null | undefined, options?: IResourceOptions): URI | null {
@@ -1000,35 +1004,20 @@ export function toResource(editor: IEditorInput | null | undefined, options?: IR
return null;
}
// Check for side by side if we are asked to
if (options && options.supportSideBySide && editor instanceof SideBySideEditorInput) {
editor = editor.master;
editor = options.supportSideBySide === SideBySideEditor.MASTER ? editor.master : editor.details;
}
const resource = editor.getResource();
if (!options || !options.filter) {
return types.withUndefinedAsNull(resource); // return early if no filter is specified
if (!resource || !options || !options.filterByScheme) {
return withUndefinedAsNull(resource);
}
if (!resource) {
return null;
}
let includeFiles: boolean;
let includeUntitled: boolean;
if (Array.isArray(options.filter)) {
includeFiles = (options.filter.indexOf(Schemas.file) >= 0);
includeUntitled = (options.filter.indexOf(Schemas.untitled) >= 0);
} else {
includeFiles = (options.filter === Schemas.file);
includeUntitled = (options.filter === Schemas.untitled);
}
if (includeFiles && resource.scheme === Schemas.file) {
if (Array.isArray(options.filterByScheme) && options.filterByScheme.some(scheme => resource.scheme === scheme)) {
return resource;
}
if (includeUntitled && resource.scheme === Schemas.untitled) {
if (options.filterByScheme === resource.scheme) {
return resource;
}

View File

@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import { Event, Emitter } from 'vs/base/common/event';
import { Extensions, IEditorInputFactoryRegistry, EditorInput, toResource, IEditorIdentifier, IEditorCloseEvent, GroupIdentifier, SideBySideEditorInput, CloseDirection, IEditorInput } from 'vs/workbench/common/editor';
import { Extensions, IEditorInputFactoryRegistry, EditorInput, toResource, IEditorIdentifier, IEditorCloseEvent, GroupIdentifier, SideBySideEditorInput, CloseDirection, IEditorInput, SideBySideEditor } from 'vs/workbench/common/editor';
import { URI } from 'vs/base/common/uri';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IConfigurationService, IConfigurationChangeEvent } from 'vs/platform/configuration/common/configuration';
@@ -157,7 +157,7 @@ export class EditorGroup extends Disposable {
}
for (const editor of this.editors) {
const editorResource = toResource(editor, { supportSideBySide: true });
const editorResource = toResource(editor, { supportSideBySide: SideBySideEditor.MASTER });
if (editorResource && editorResource.toString() === resource.toString()) {
return editor;
}
@@ -541,7 +541,7 @@ export class EditorGroup extends Disposable {
}
private updateResourceMap(editor: EditorInput, remove: boolean): void {
const resource = toResource(editor, { supportSideBySide: true });
const resource = toResource(editor, { supportSideBySide: SideBySideEditor.MASTER });
if (resource) {
// It is possible to have the same resource opened twice (once as normal input and once as diff input)