@@ -15,7 +15,7 @@ import { ICommand, IConfiguration, ScrollType } from 'vs/editor/common/editorCom
15
15
import { ITextModel , TextModelResolvedOptions } from 'vs/editor/common/model' ;
16
16
import { TextModel } from 'vs/editor/common/model/textModel' ;
17
17
import { LanguageIdentifier } from 'vs/editor/common/modes' ;
18
- import { IAutoClosingPair } from 'vs/editor/common/modes/languageConfiguration' ;
18
+ import { IAutoClosingPair , StandardAutoClosingPairConditional } from 'vs/editor/common/modes/languageConfiguration' ;
19
19
import { LanguageConfigurationRegistry } from 'vs/editor/common/modes/languageConfigurationRegistry' ;
20
20
import { VerticalRevealType } from 'vs/editor/common/view/viewEvents' ;
21
21
import { IViewModel } from 'vs/editor/common/viewModel/viewModel' ;
@@ -67,11 +67,22 @@ export interface ICursors {
67
67
export interface CharacterMap {
68
68
[ char : string ] : string ;
69
69
}
70
+ export interface MultipleCharacterMap {
71
+ [ char : string ] : string [ ] ;
72
+ }
70
73
71
74
const autoCloseAlways = ( ) => true ;
72
75
const autoCloseNever = ( ) => false ;
73
76
const autoCloseBeforeWhitespace = ( chr : string ) => ( chr === ' ' || chr === '\t' ) ;
74
77
78
+ function appendEntry < K , V > ( target : Map < K , V [ ] > , key : K , value : V ) : void {
79
+ if ( target . has ( key ) ) {
80
+ target . get ( key ) ! . push ( value ) ;
81
+ } else {
82
+ target . set ( key , [ value ] ) ;
83
+ }
84
+ }
85
+
75
86
export class CursorConfiguration {
76
87
_cursorMoveConfigurationBrand : void ;
77
88
@@ -90,8 +101,8 @@ export class CursorConfiguration {
90
101
public readonly autoClosingQuotes : EditorAutoClosingStrategy ;
91
102
public readonly autoSurround : EditorAutoSurroundStrategy ;
92
103
public readonly autoIndent : boolean ;
93
- public readonly autoClosingPairsOpen : CharacterMap ;
94
- public readonly autoClosingPairsClose : CharacterMap ;
104
+ public readonly autoClosingPairsOpen2 : Map < string , StandardAutoClosingPairConditional [ ] > ;
105
+ public readonly autoClosingPairsClose2 : Map < string , StandardAutoClosingPairConditional [ ] > ;
95
106
public readonly surroundingPairs : CharacterMap ;
96
107
public readonly shouldAutoCloseBefore : { quote : ( ch : string ) => boolean , bracket : ( ch : string ) => boolean } ;
97
108
@@ -138,8 +149,8 @@ export class CursorConfiguration {
138
149
this . autoSurround = c . autoSurround ;
139
150
this . autoIndent = c . autoIndent ;
140
151
141
- this . autoClosingPairsOpen = { } ;
142
- this . autoClosingPairsClose = { } ;
152
+ this . autoClosingPairsOpen2 = new Map < string , StandardAutoClosingPairConditional [ ] > ( ) ;
153
+ this . autoClosingPairsClose2 = new Map < string , StandardAutoClosingPairConditional [ ] > ( ) ;
143
154
this . surroundingPairs = { } ;
144
155
this . _electricChars = null ;
145
156
@@ -151,8 +162,10 @@ export class CursorConfiguration {
151
162
let autoClosingPairs = CursorConfiguration . _getAutoClosingPairs ( languageIdentifier ) ;
152
163
if ( autoClosingPairs ) {
153
164
for ( const pair of autoClosingPairs ) {
154
- this . autoClosingPairsOpen [ pair . open ] = pair . close ;
155
- this . autoClosingPairsClose [ pair . close ] = pair . open ;
165
+ appendEntry ( this . autoClosingPairsOpen2 , pair . open . charAt ( pair . open . length - 1 ) , pair ) ;
166
+ if ( pair . close . length === 1 ) {
167
+ appendEntry ( this . autoClosingPairsClose2 , pair . close , pair ) ;
168
+ }
156
169
}
157
170
}
158
171
@@ -190,7 +203,7 @@ export class CursorConfiguration {
190
203
}
191
204
}
192
205
193
- private static _getAutoClosingPairs ( languageIdentifier : LanguageIdentifier ) : IAutoClosingPair [ ] | null {
206
+ private static _getAutoClosingPairs ( languageIdentifier : LanguageIdentifier ) : StandardAutoClosingPairConditional [ ] | null {
194
207
try {
195
208
return LanguageConfigurationRegistry . getAutoClosingPairs ( languageIdentifier . id ) ;
196
209
} catch ( e ) {
0 commit comments