Skip to content

Commit 7cb8e45

Browse files
committed
remove autoClosingPairs, surroundingPair in favour of deprecated api and language config file, fixes microsoft#8737
1 parent fa7ce99 commit 7cb8e45

7 files changed

Lines changed: 66 additions & 75 deletions

File tree

extensions/css/client/src/cssMain.ts

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,15 @@ export function activate(context: ExtensionContext) {
5959
blockComment: ['/*', '*/']
6060
},
6161
brackets: [['{', '}'], ['[', ']'], ['(', ')']],
62-
autoClosingPairs: [
63-
{ open: '{', close: '}' },
64-
{ open: '[', close: ']' },
65-
{ open: '(', close: ')' },
66-
{ open: '"', close: '"', notIn: ['string'] },
67-
{ open: '\'', close: '\'', notIn: ['string'] }
68-
]
62+
__characterPairSupport: {
63+
autoClosingPairs: [
64+
{ open: '{', close: '}' },
65+
{ open: '[', close: ']' },
66+
{ open: '(', close: ')' },
67+
{ open: '"', close: '"', notIn: ['string'] },
68+
{ open: '\'', close: '\'', notIn: ['string'] }
69+
]
70+
}
6971
});
7072

7173
languages.setLanguageConfiguration('less', {
@@ -75,14 +77,16 @@ export function activate(context: ExtensionContext) {
7577
lineComment: '//'
7678
},
7779
brackets: [['{', '}'], ['[', ']'], ['(', ')'], ['<', '>']],
78-
autoClosingPairs: [
79-
{ open: '"', close: '"', notIn: ['string', 'comment'] },
80-
{ open: '\'', close: '\'', notIn: ['string', 'comment'] },
81-
{ open: '{', close: '}', notIn: ['string', 'comment'] },
82-
{ open: '[', close: ']', notIn: ['string', 'comment'] },
83-
{ open: '(', close: ')', notIn: ['string', 'comment'] },
84-
{ open: '<', close: '>', notIn: ['string', 'comment'] },
85-
]
80+
__characterPairSupport: {
81+
autoClosingPairs: [
82+
{ open: '"', close: '"', notIn: ['string', 'comment'] },
83+
{ open: '\'', close: '\'', notIn: ['string', 'comment'] },
84+
{ open: '{', close: '}', notIn: ['string', 'comment'] },
85+
{ open: '[', close: ']', notIn: ['string', 'comment'] },
86+
{ open: '(', close: ')', notIn: ['string', 'comment'] },
87+
{ open: '<', close: '>', notIn: ['string', 'comment'] },
88+
]
89+
}
8690
});
8791

8892
languages.setLanguageConfiguration('scss', {
@@ -92,14 +96,16 @@ export function activate(context: ExtensionContext) {
9296
lineComment: '//'
9397
},
9498
brackets: [['{', '}'], ['[', ']'], ['(', ')'], ['<', '>']],
95-
autoClosingPairs: [
96-
{ open: '"', close: '"', notIn: ['string', 'comment'] },
97-
{ open: '\'', close: '\'', notIn: ['string', 'comment'] },
98-
{ open: '{', close: '}', notIn: ['string', 'comment'] },
99-
{ open: '[', close: ']', notIn: ['string', 'comment'] },
100-
{ open: '(', close: ')', notIn: ['string', 'comment'] },
101-
{ open: '<', close: '>', notIn: ['string', 'comment'] },
102-
]
99+
__characterPairSupport: {
100+
autoClosingPairs: [
101+
{ open: '"', close: '"', notIn: ['string', 'comment'] },
102+
{ open: '\'', close: '\'', notIn: ['string', 'comment'] },
103+
{ open: '{', close: '}', notIn: ['string', 'comment'] },
104+
{ open: '[', close: ']', notIn: ['string', 'comment'] },
105+
{ open: '(', close: ')', notIn: ['string', 'comment'] },
106+
{ open: '<', close: '>', notIn: ['string', 'comment'] },
107+
]
108+
}
103109
});
104110

105111
commands.registerCommand('_css.applyCodeAction', applyCodeAction);

extensions/json/client/src/jsonMain.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,16 @@ export function activate(context: ExtensionContext) {
9090

9191
languages.setLanguageConfiguration('json', {
9292
wordPattern: /(-?\d*\.\d\w*)|([^\[\{\]\}\:\"\,\s]+)/g,
93-
autoClosingPairs: [
94-
{ open: '{', close: '}' },
95-
{ open: '[', close: ']' },
96-
{ open: '(', close: ')' },
97-
{ open: '"', close: '"', notIn: ['string'] },
98-
{ open: '\'', close: '\'', notIn: ['string', 'comment'] },
99-
{ open: '`', close: '`', notIn: ['string', 'comment'] }
100-
]
93+
__characterPairSupport: {
94+
autoClosingPairs: [
95+
{ open: '{', close: '}' },
96+
{ open: '[', close: ']' },
97+
{ open: '(', close: ')' },
98+
{ open: '"', close: '"', notIn: ['string'] },
99+
{ open: '\'', close: '\'', notIn: ['string', 'comment'] },
100+
{ open: '`', close: '`', notIn: ['string', 'comment'] }
101+
]
102+
}
101103
});
102104
});
103105
}

extensions/php/src/phpMain.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,14 @@ export function activate(context: ExtensionContext): any {
2828
languages.setLanguageConfiguration('php', {
2929
wordPattern: /(-?\d*\.\d\w*)|([^\-\`\~\!\@\#\%\^\&\*\(\)\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g,
3030

31-
autoClosingPairs: [
32-
{ open: '{', close: '}' },
33-
{ open: '[', close: ']' },
34-
{ open: '(', close: ')' },
35-
{ open: '"', close: '"', notIn: ['string'] },
36-
{ open: '\'', close: '\'', notIn: ['string', 'comment'] }
37-
]
31+
__characterPairSupport: {
32+
autoClosingPairs: [
33+
{ open: '{', close: '}' },
34+
{ open: '[', close: ']' },
35+
{ open: '(', close: ')' },
36+
{ open: '"', close: '"', notIn: ['string'] },
37+
{ open: '\'', close: '\'', notIn: ['string', 'comment'] }
38+
]
39+
}
3840
});
3941
}

extensions/typescript/src/typescriptMain.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -210,14 +210,16 @@ class LanguageProvider {
210210
docComment: { scope: 'comment.documentation', open: '/**', lineStart: ' * ', close: ' */' }
211211
},
212212

213-
autoClosingPairs: [
214-
{ open: '{', close: '}' },
215-
{ open: '[', close: ']' },
216-
{ open: '(', close: ')' },
217-
{ open: '"', close: '"', notIn: ['string'] },
218-
{ open: '\'', close: '\'', notIn: ['string', 'comment'] },
219-
{ open: '`', close: '`', notIn: ['string', 'comment'] }
220-
]
213+
__characterPairSupport: {
214+
autoClosingPairs: [
215+
{ open: '{', close: '}' },
216+
{ open: '[', close: ']' },
217+
{ open: '(', close: ')' },
218+
{ open: '"', close: '"', notIn: ['string'] },
219+
{ open: '\'', close: '\'', notIn: ['string', 'comment'] },
220+
{ open: '`', close: '`', notIn: ['string', 'comment'] }
221+
]
222+
}
221223
});
222224
});
223225
}

src/vs/vscode.d.ts

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2447,26 +2447,6 @@ declare namespace vscode {
24472447
*/
24482448
onEnterRules?: OnEnterRule[];
24492449

2450-
/**
2451-
* The language's auto closing pairs. The 'close' character is automatically inserted with the
2452-
* 'open' character is typed. If not set, the configured brackets will be used.
2453-
*/
2454-
autoClosingPairs?: {
2455-
open: string;
2456-
close: string;
2457-
notIn?: string[];
2458-
}[];
2459-
2460-
/**
2461-
* The language's surrounding pairs. When the 'open' character is typed on a selection, the
2462-
* selected string is surrounded by the open and close characters. If not set, the autoclosing pairs
2463-
* settings will be used.
2464-
*/
2465-
surroundingPairs?: {
2466-
open: string;
2467-
close: string;
2468-
}[];
2469-
24702450
/**
24712451
* **Deprecated** Do not use.
24722452
*
@@ -2490,7 +2470,7 @@ declare namespace vscode {
24902470
/**
24912471
* **Deprecated** Do not use.
24922472
*
2493-
* @deprecated Use autoClosingPairs and surroundingPairs instead.
2473+
* @deprecated Use the language configuration file instead.
24942474
*/
24952475
__characterPairSupport?: {
24962476
autoClosingPairs: {

src/vs/workbench/api/node/extHostLanguageFeatures.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -837,12 +837,6 @@ export class ExtHostLanguageFeatures {
837837
this._documents.setWordDefinitionFor(languageId, null);
838838
}
839839

840-
// backward compatibility, migrate deprecated setting
841-
if (configuration.__characterPairSupport && !configuration.autoClosingPairs) {
842-
configuration.autoClosingPairs = configuration.__characterPairSupport.autoClosingPairs;
843-
delete configuration.__characterPairSupport;
844-
}
845-
846840
const handle = this._nextHandle();
847841
this._proxy.$setLanguageConfiguration(handle, languageId, configuration);
848842
return this._createDisposable(handle);

src/vs/workbench/api/node/mainThreadLanguageFeatures.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {CancellationToken} from 'vs/base/common/cancellation';
1616
import {Position as EditorPosition} from 'vs/editor/common/core/position';
1717
import {Range as EditorRange} from 'vs/editor/common/core/range';
1818
import {ExtHostContext, ExtHostLanguageFeaturesShape} from './extHostProtocol';
19-
import {LanguageConfigurationRegistry} from 'vs/editor/common/modes/languageConfigurationRegistry';
19+
import {LanguageConfigurationRegistry, LanguageConfiguration} from 'vs/editor/common/modes/languageConfigurationRegistry';
2020

2121
export class MainThreadLanguageFeatures {
2222

@@ -203,7 +203,12 @@ export class MainThreadLanguageFeatures {
203203

204204
// --- configuration
205205

206-
$setLanguageConfiguration(handle: number, languageId:string, configuration: vscode.LanguageConfiguration): TPromise<any> {
206+
$setLanguageConfiguration(handle: number, languageId: string, configuration: vscode.LanguageConfiguration): TPromise<any> {
207+
208+
if (configuration.__characterPairSupport) {
209+
(<LanguageConfiguration> configuration).autoClosingPairs = configuration.__characterPairSupport.autoClosingPairs;
210+
}
211+
207212
this._registrations[handle] = LanguageConfigurationRegistry.register(languageId, configuration);
208213
return undefined;
209214
}

0 commit comments

Comments
 (0)