@@ -997,7 +997,6 @@ export interface InternalEditorViewOptions {
997997 readonly renderLineNumbers : RenderLineNumbersType ;
998998 readonly renderCustomLineNumbers : ( ( lineNumber : number ) => string ) | null ;
999999 readonly cursorSurroundingLines : number ;
1000- readonly renderFinalNewline : boolean ;
10011000 readonly selectOnLineNumbers : boolean ;
10021001 readonly glyphMargin : boolean ;
10031002 readonly revealHorizontalRightPadding : number ;
@@ -1230,8 +1229,14 @@ export class InternalEditorOptions {
12301229 /**
12311230 * @internal
12321231 */
1233- public createChangeEvent ( newOpts : InternalEditorOptions ) : IConfigurationChangedEvent {
1232+ public createChangeEvent ( newOpts : InternalEditorOptions , changeEvent : ChangedEditorOptions | null ) : IConfigurationChangedEvent {
12341233 return {
1234+ hasChanged : ( id : EditorOptionId ) => {
1235+ if ( ! changeEvent ) {
1236+ return false ;
1237+ }
1238+ return changeEvent . get ( id ) ;
1239+ } ,
12351240 canUseLayerHinting : ( this . canUseLayerHinting !== newOpts . canUseLayerHinting ) ,
12361241 pixelRatio : ( this . pixelRatio !== newOpts . pixelRatio ) ,
12371242 editorClassName : ( this . editorClassName !== newOpts . editorClassName ) ,
@@ -1312,7 +1317,6 @@ export class InternalEditorOptions {
13121317 && a . renderLineNumbers === b . renderLineNumbers
13131318 && a . renderCustomLineNumbers === b . renderCustomLineNumbers
13141319 && a . cursorSurroundingLines === b . cursorSurroundingLines
1315- && a . renderFinalNewline === b . renderFinalNewline
13161320 && a . selectOnLineNumbers === b . selectOnLineNumbers
13171321 && a . glyphMargin === b . glyphMargin
13181322 && a . revealHorizontalRightPadding === b . revealHorizontalRightPadding
@@ -1638,6 +1642,7 @@ export interface EditorLayoutInfo {
16381642 * An event describing that the configuration of the editor has changed.
16391643 */
16401644export interface IConfigurationChangedEvent {
1645+ hasChanged ( id : EditorOptionId ) : boolean ;
16411646 readonly canUseLayerHinting : boolean ;
16421647 readonly pixelRatio : boolean ;
16431648 readonly editorClassName : boolean ;
@@ -2076,7 +2081,6 @@ export class EditorOptionsValidator {
20762081 cursorSurroundingLines : _clampedInt ( opts . cursorSurroundingLines , defaults . cursorWidth , 0 , Number . MAX_VALUE ) ,
20772082 renderLineNumbers : renderLineNumbers ,
20782083 renderCustomLineNumbers : renderCustomLineNumbers ,
2079- renderFinalNewline : _boolean ( opts . renderFinalNewline , defaults . renderFinalNewline ) ,
20802084 selectOnLineNumbers : _boolean ( opts . selectOnLineNumbers , defaults . selectOnLineNumbers ) ,
20812085 glyphMargin : _boolean ( opts . glyphMargin , defaults . glyphMargin ) ,
20822086 revealHorizontalRightPadding : _clampedInt ( opts . revealHorizontalRightPadding , defaults . revealHorizontalRightPadding , 0 , 1000 ) ,
@@ -2198,7 +2202,6 @@ export class InternalEditorOptionsFactory {
21982202 renderLineNumbers : opts . viewInfo . renderLineNumbers ,
21992203 renderCustomLineNumbers : opts . viewInfo . renderCustomLineNumbers ,
22002204 cursorSurroundingLines : opts . viewInfo . cursorSurroundingLines ,
2201- renderFinalNewline : opts . viewInfo . renderFinalNewline ,
22022205 selectOnLineNumbers : opts . viewInfo . selectOnLineNumbers ,
22032206 glyphMargin : opts . viewInfo . glyphMargin ,
22042207 revealHorizontalRightPadding : opts . viewInfo . revealHorizontalRightPadding ,
@@ -2665,7 +2668,6 @@ export const EDITOR_DEFAULTS: IValidatedEditorOptions = {
26652668 renderLineNumbers : RenderLineNumbersType . On ,
26662669 renderCustomLineNumbers : null ,
26672670 cursorSurroundingLines : 0 ,
2668- renderFinalNewline : true ,
26692671 selectOnLineNumbers : true ,
26702672 glyphMargin : true ,
26712673 revealHorizontalRightPadding : 30 ,
@@ -2770,3 +2772,127 @@ export const EDITOR_DEFAULTS: IValidatedEditorOptions = {
27702772 codeActionsOnSaveTimeout : 750
27712773 } ,
27722774} ;
2775+
2776+ export interface IRawEditorOptionsBag {
2777+ [ key : string ] : any ;
2778+ }
2779+
2780+ /**
2781+ * @internal
2782+ */
2783+ export class RawEditorOptions {
2784+ private readonly _values : any [ ] = [ ] ;
2785+ public _read < T > ( id : EditorOptionId ) : T | undefined {
2786+ return this . _values [ id ] ;
2787+ }
2788+ public _write < T > ( id : EditorOptionId , value : T | undefined ) : void {
2789+ this . _values [ id ] = value ;
2790+ }
2791+ }
2792+
2793+ /**
2794+ * @internal
2795+ */
2796+ export class ValidatedEditorOptions {
2797+ private readonly _values : any [ ] = [ ] ;
2798+ public _read < T > ( option : EditorOptionId ) : T {
2799+ return this . _values [ option ] ;
2800+ }
2801+ public _write < T > ( option : EditorOptionId , value : T ) : void {
2802+ this . _values [ option ] = value ;
2803+ }
2804+ }
2805+
2806+ export interface IComputedEditorOptions {
2807+ get < T1 , T2 , T3 > ( id : EditorOptionId , option : IEditorOption < T1 , T2 , T3 > ) : T3 ;
2808+ }
2809+
2810+ /**
2811+ * @internal
2812+ */
2813+ export class ComputedEditorOptions {
2814+ private readonly _values : any [ ] = [ ] ;
2815+ public _read < T > ( id : EditorOptionId ) : T {
2816+ return this . _values [ id ] ;
2817+ }
2818+ public get < T1 , T2 , T3 > ( id : EditorOptionId , option : IEditorOption < T1 , T2 , T3 > ) : T3 {
2819+ return this . _values [ id ] ;
2820+ }
2821+ public _write < T > ( id : EditorOptionId , value : T ) : void {
2822+ this . _values [ id ] = value ;
2823+ }
2824+ }
2825+
2826+ /**
2827+ * @internal
2828+ */
2829+ export class ChangedEditorOptions {
2830+ private readonly _values : boolean [ ] = [ ] ;
2831+ public get ( id : EditorOptionId ) : boolean {
2832+ return this . _values [ id ] ;
2833+ }
2834+ public _write ( id : EditorOptionId , value : boolean ) : void {
2835+ this . _values [ id ] = value ;
2836+ }
2837+ }
2838+
2839+ interface IEditorOption < T1 , T2 = T1 , T3 = T2 > {
2840+ readonly id : EditorOptionId ;
2841+ readonly name : string ;
2842+ readonly defaultValue : T1 ;
2843+ read ( options : IRawEditorOptionsBag ) : T1 | undefined ;
2844+ mix ( a : T1 | undefined , b : T1 | undefined ) : T1 | undefined ;
2845+ validate ( input : T1 | undefined ) : T2 ;
2846+ compute ( value : T2 ) : T3 ;
2847+ equals ( a : T3 , b : T3 ) : boolean ;
2848+ }
2849+
2850+ class BooleanEditorOption implements IEditorOption < boolean > {
2851+ public readonly id : EditorOptionId ;
2852+ public readonly name : string ;
2853+ public readonly defaultValue : boolean ;
2854+
2855+ constructor ( id : EditorOptionId , name : string , defaultValue : boolean ) {
2856+ this . id = id ;
2857+ this . name = name ;
2858+ this . defaultValue = defaultValue ;
2859+ }
2860+
2861+ public read ( options : IRawEditorOptionsBag ) : boolean | undefined {
2862+ return options [ this . name ] ;
2863+ }
2864+
2865+ public mix ( a : boolean | undefined , b : boolean | undefined ) : boolean | undefined {
2866+ return ( typeof b !== 'undefined' ? b : a ) ;
2867+ }
2868+
2869+ public validate ( input : boolean | undefined ) : boolean {
2870+ return _boolean ( input , this . defaultValue ) ;
2871+ }
2872+
2873+ public compute ( value : boolean ) : boolean {
2874+ return value ;
2875+ }
2876+
2877+ public equals ( a : boolean , b : boolean ) : boolean {
2878+ return ( a === b ) ;
2879+ }
2880+ }
2881+
2882+ /**
2883+ * @internal
2884+ */
2885+ export const editorOptionsRegistry : IEditorOption < any > [ ] = [ ] ;
2886+
2887+ function registerEditorOption < T1 , T2 , T3 > ( option : IEditorOption < T1 , T2 , T3 > ) : IEditorOption < T1 , T2 , T3 > {
2888+ editorOptionsRegistry [ option . id ] = option ;
2889+ return option ;
2890+ }
2891+
2892+ export const enum EditorOptionId {
2893+ RenderFinalNewline ,
2894+ }
2895+
2896+ export const EditorOption = {
2897+ RenderFinalNewline : registerEditorOption ( new BooleanEditorOption ( EditorOptionId . RenderFinalNewline , 'renderFinalNewline' , true ) )
2898+ } ;
0 commit comments