@@ -10,7 +10,7 @@ import { withNullAsUndefined, assertIsDefined } from 'vs/base/common/types';
1010import { URI } from 'vs/base/common/uri' ;
1111import { IDisposable , Disposable , toDisposable } from 'vs/base/common/lifecycle' ;
1212import { IEditor as ICodeEditor , IEditorViewState , ScrollType , IDiffEditor } from 'vs/editor/common/editorCommon' ;
13- import { IEditorModel , IEditorOptions , ITextEditorOptions , IBaseResourceInput , IResourceInput , EditorActivation , EditorOpenContext , ITextEditorSelection } from 'vs/platform/editor/common/editor' ;
13+ import { IEditorModel , IEditorOptions , ITextEditorOptions , IBaseResourceInput , IResourceInput , EditorActivation , EditorOpenContext , ITextEditorSelection , TextEditorSelectionRevealType } from 'vs/platform/editor/common/editor' ;
1414import { IInstantiationService , IConstructorSignature0 , ServicesAccessor , BrandedService } from 'vs/platform/instantiation/common/instantiation' ;
1515import { RawContextKey , ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey' ;
1616import { Registry } from 'vs/platform/registry/common/platform' ;
@@ -1110,16 +1110,9 @@ export class TextEditorOptions extends EditorOptions implements ITextEditorOptio
11101110 editorViewState : IEditorViewState | undefined ;
11111111
11121112 /**
1113- * Option to scroll vertically or horizontally as necessary and reveal a range centered vertically only if it lies outside the viewport.
1114- * This can't be used in combination with revealAtDefinition.
1113+ * Option to control the text editor selection reveal type.
11151114 */
1116- revealInCenterIfOutsideViewport : boolean | undefined ;
1117-
1118- /**
1119- * Option to scroll vertically or horizontally as necessary and reveal a range close to the top of the viewport,
1120- * optimized for viewing a code definition.
1121- */
1122- revealAtDefinition : boolean | undefined ;
1115+ selectionRevealType : TextEditorSelectionRevealType | undefined ;
11231116
11241117 static from ( input ?: IBaseResourceInput ) : TextEditorOptions | undefined {
11251118 if ( ! input || ! input . options ) {
@@ -1158,15 +1151,8 @@ export class TextEditorOptions extends EditorOptions implements ITextEditorOptio
11581151 this . editorViewState = options . viewState as IEditorViewState ;
11591152 }
11601153
1161- if ( typeof options . revealAtDefinition === 'boolean' ) {
1162- this . revealAtDefinition = options . revealAtDefinition ;
1163- if ( options . revealInCenterIfOutsideViewport ) {
1164- throw new Error ( 'revealInCenterIfOutsideViewport and revealAtDefinition cannot both be true' ) ;
1165- }
1166- }
1167-
1168- if ( typeof options . revealInCenterIfOutsideViewport === 'boolean' ) {
1169- this . revealInCenterIfOutsideViewport = options . revealInCenterIfOutsideViewport ;
1154+ if ( typeof options . selectionRevealType !== 'undefined' ) {
1155+ this . selectionRevealType = options . selectionRevealType ;
11701156 }
11711157
11721158 return this ;
@@ -1176,7 +1162,7 @@ export class TextEditorOptions extends EditorOptions implements ITextEditorOptio
11761162 * Returns if this options object has objects defined for the editor.
11771163 */
11781164 hasOptionsDefined ( ) : boolean {
1179- return ! ! this . editorViewState || ! ! this . revealInCenterIfOutsideViewport || ! ! this . selection ;
1165+ return ! ! this . editorViewState || ! ! this . selectionRevealType || ! ! this . selection ;
11801166 }
11811167
11821168 /**
@@ -1216,9 +1202,9 @@ export class TextEditorOptions extends EditorOptions implements ITextEditorOptio
12161202
12171203 editor . setSelection ( range ) ;
12181204
1219- if ( this . revealAtDefinition ) {
1205+ if ( this . selectionRevealType === TextEditorSelectionRevealType . Definition ) {
12201206 editor . revealRangeAtDefinition ( range , scrollType ) ;
1221- } else if ( this . revealInCenterIfOutsideViewport ) {
1207+ } else if ( this . selectionRevealType === TextEditorSelectionRevealType . CenterIfOutsideViewport ) {
12221208 editor . revealRangeInCenterIfOutsideViewport ( range , scrollType ) ;
12231209 } else {
12241210 editor . revealRangeInCenter ( range , scrollType ) ;
0 commit comments