@@ -46,18 +46,23 @@ export interface IIndentConverter {
4646export class RichEditSupport {
4747
4848 private readonly _conf : LanguageConfiguration ;
49+ private readonly _languageIdentifier : LanguageIdentifier ;
50+ private _brackets : RichEditBrackets ;
51+ private _electricCharacter : BracketElectricCharacterSupport ;
4952
50- public readonly electricCharacter : BracketElectricCharacterSupport ;
5153 public readonly comments : ICommentsConfiguration ;
5254 public readonly characterPair : CharacterPairSupport ;
5355 public readonly wordDefinition : RegExp ;
5456 public readonly onEnter : OnEnterSupport ;
5557 public readonly indentRulesSupport : IndentRulesSupport ;
56- public readonly brackets : RichEditBrackets ;
5758 public readonly indentationRules : IndentationRule ;
5859 public readonly foldingRules : FoldingRules ;
5960
6061 constructor ( languageIdentifier : LanguageIdentifier , previous : RichEditSupport , rawConf : LanguageConfiguration ) {
62+ this . _languageIdentifier = languageIdentifier ;
63+
64+ this . _brackets = null ;
65+ this . _electricCharacter = null ;
6166
6267 let prev : LanguageConfiguration = null ;
6368 if ( previous ) {
@@ -66,16 +71,11 @@ export class RichEditSupport {
6671
6772 this . _conf = RichEditSupport . _mergeConf ( prev , rawConf ) ;
6873
69- if ( this . _conf . brackets ) {
70- this . brackets = new RichEditBrackets ( languageIdentifier , this . _conf . brackets ) ;
71- }
72-
7374 this . onEnter = RichEditSupport . _handleOnEnter ( this . _conf ) ;
7475
7576 this . comments = RichEditSupport . _handleComments ( this . _conf ) ;
7677
7778 this . characterPair = new CharacterPairSupport ( this . _conf ) ;
78- this . electricCharacter = new BracketElectricCharacterSupport ( this . brackets , this . characterPair . getAutoClosingPairs ( ) , this . _conf . __electricCharacterSupport ) ;
7979
8080 this . wordDefinition = this . _conf . wordPattern || DEFAULT_WORD_REGEXP ;
8181
@@ -87,6 +87,20 @@ export class RichEditSupport {
8787 this . foldingRules = this . _conf . folding || { } ;
8888 }
8989
90+ public get brackets ( ) : RichEditBrackets {
91+ if ( ! this . _brackets && this . _conf . brackets ) {
92+ this . _brackets = new RichEditBrackets ( this . _languageIdentifier , this . _conf . brackets ) ;
93+ }
94+ return this . _brackets ;
95+ }
96+
97+ public get electricCharacter ( ) : BracketElectricCharacterSupport {
98+ if ( ! this . _electricCharacter ) {
99+ this . _electricCharacter = new BracketElectricCharacterSupport ( this . brackets , this . characterPair . getAutoClosingPairs ( ) , this . _conf . __electricCharacterSupport ) ;
100+ }
101+ return this . _electricCharacter ;
102+ }
103+
90104 private static _mergeConf ( prev : LanguageConfiguration , current : LanguageConfiguration ) : LanguageConfiguration {
91105 return {
92106 comments : ( prev ? current . comments || prev . comments : current . comments ) ,
0 commit comments