44 *--------------------------------------------------------------------------------------------*/
55
66import { Event , Emitter } from 'vs/base/common/event' ;
7- import * as objects from 'vs/base/common/objects' ;
8- import * as types from 'vs/base/common/types' ;
7+ import { assign } from 'vs/base/common/objects' ;
8+ import { isUndefinedOrNull , withUndefinedAsNull } from 'vs/base/common/types' ;
99import { URI } from 'vs/base/common/uri' ;
1010import { IDisposable , Disposable } from 'vs/base/common/lifecycle' ;
1111import { IEditor as ICodeEditor , IEditorViewState , ScrollType , IDiffEditor } from 'vs/editor/common/editorCommon' ;
@@ -14,7 +14,6 @@ import { IInstantiationService, IConstructorSignature0, ServicesAccessor } from
1414import { RawContextKey , ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey' ;
1515import { Registry } from 'vs/platform/registry/common/platform' ;
1616import { ITextModel } from 'vs/editor/common/model' ;
17- import { Schemas } from 'vs/base/common/network' ;
1817import { IEditorGroup } from 'vs/workbench/services/editor/common/editorGroupsService' ;
1918import { ICompositeControl } from 'vs/workbench/common/composite' ;
2019import { ActionRunner , IAction } from 'vs/base/common/actions' ;
@@ -571,7 +570,7 @@ export class SideBySideEditorInput extends EditorInput {
571570 getTelemetryDescriptor ( ) : object {
572571 const descriptor = this . master . getTelemetryDescriptor ( ) ;
573572
574- return objects . assign ( descriptor , super . getTelemetryDescriptor ( ) ) ;
573+ return assign ( descriptor , super . getTelemetryDescriptor ( ) ) ;
575574 }
576575
577576 private registerListeners ( ) : void {
@@ -827,7 +826,7 @@ export class TextEditorOptions extends EditorOptions {
827826 * Returns if this options object has objects defined for the editor.
828827 */
829828 hasOptionsDefined ( ) : boolean {
830- return ! ! this . editorViewState || ( ! types . isUndefinedOrNull ( this . startLineNumber ) && ! types . isUndefinedOrNull ( this . startColumn ) ) ;
829+ return ! ! this . editorViewState || ( ! isUndefinedOrNull ( this . startLineNumber ) && ! isUndefinedOrNull ( this . startColumn ) ) ;
831830 }
832831
833832 /**
@@ -875,10 +874,10 @@ export class TextEditorOptions extends EditorOptions {
875874 }
876875
877876 // Otherwise check for selection
878- else if ( ! types . isUndefinedOrNull ( this . startLineNumber ) && ! types . isUndefinedOrNull ( this . startColumn ) ) {
877+ else if ( ! isUndefinedOrNull ( this . startLineNumber ) && ! isUndefinedOrNull ( this . startColumn ) ) {
879878
880879 // Select
881- if ( ! types . isUndefinedOrNull ( this . endLineNumber ) && ! types . isUndefinedOrNull ( this . endColumn ) ) {
880+ if ( ! isUndefinedOrNull ( this . endLineNumber ) && ! isUndefinedOrNull ( this . endColumn ) ) {
882881 const range = {
883882 startLineNumber : this . startLineNumber ,
884883 startColumn : this . startColumn ,
@@ -986,43 +985,28 @@ export enum SideBySideEditor {
986985
987986export interface IResourceOptions {
988987 supportSideBySide ?: SideBySideEditor ;
989- filter ?: string | string [ ] ;
988+ filterByScheme ?: string | string [ ] ;
990989}
991990
992991export function toResource ( editor : IEditorInput | null | undefined , options ?: IResourceOptions ) : URI | null {
993992 if ( ! editor ) {
994993 return null ;
995994 }
996995
997- // Check for side by side if we are asked to
998996 if ( options && options . supportSideBySide && editor instanceof SideBySideEditorInput ) {
999997 editor = options . supportSideBySide === SideBySideEditor . MASTER ? editor . master : editor . details ;
1000998 }
1001999
10021000 const resource = editor . getResource ( ) ;
1003- if ( ! options || ! options . filter ) {
1004- return types . withUndefinedAsNull ( resource ) ; // return early if no filter is specified
1001+ if ( ! resource || ! options || ! options . filterByScheme ) {
1002+ return withUndefinedAsNull ( resource ) ;
10051003 }
10061004
1007- if ( ! resource ) {
1008- return null ;
1009- }
1010-
1011- let includeFiles : boolean ;
1012- let includeUntitled : boolean ;
1013- if ( Array . isArray ( options . filter ) ) {
1014- includeFiles = ( options . filter . indexOf ( Schemas . file ) >= 0 ) ;
1015- includeUntitled = ( options . filter . indexOf ( Schemas . untitled ) >= 0 ) ;
1016- } else {
1017- includeFiles = ( options . filter === Schemas . file ) ;
1018- includeUntitled = ( options . filter === Schemas . untitled ) ;
1019- }
1020-
1021- if ( includeFiles && resource . scheme === Schemas . file ) {
1005+ if ( Array . isArray ( options . filterByScheme ) && options . filterByScheme . some ( scheme => resource . scheme === scheme ) ) {
10221006 return resource ;
10231007 }
10241008
1025- if ( includeUntitled && resource . scheme === Schemas . untitled ) {
1009+ if ( options . filterByScheme === resource . scheme ) {
10261010 return resource ;
10271011 }
10281012
0 commit comments