Skip to content

Commit 8e1ae0d

Browse files
authored
Add proposed api to support auto closing pairs on langauge configuration (microsoft#186567)
* adding support for auto closing pair
1 parent 406618d commit 8e1ae0d

File tree

5 files changed

+32
-1
lines changed

5 files changed

+32
-1
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -852,7 +852,9 @@ export class MainThreadLanguageFeatures extends Disposable implements MainThread
852852
__electricCharacterSupport: undefined
853853
};
854854

855-
if (_configuration.__characterPairSupport) {
855+
if (_configuration.autoClosingPairs) {
856+
configuration.autoClosingPairs = _configuration.autoClosingPairs;
857+
} else if (_configuration.__characterPairSupport) {
856858
// backwards compatibility
857859
configuration.autoClosingPairs = _configuration.__characterPairSupport.autoClosingPairs;
858860
}

src/vs/workbench/api/common/extHost.protocol.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,11 @@ export interface ILanguageConfigurationDto {
344344
notIn?: string[];
345345
}[];
346346
};
347+
autoClosingPairs?: {
348+
open: string;
349+
close: string;
350+
notIn?: string[];
351+
}[];
347352
}
348353

349354
export type GlobPattern = string | IRelativePattern;

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2533,6 +2533,10 @@ export class ExtHostLanguageFeatures implements extHostProtocol.ExtHostLanguageF
25332533
`Do not use.`);
25342534
}
25352535

2536+
if (configuration.autoClosingPairs) {
2537+
checkProposedApiEnabled(extension, 'languageConfigurationAutoClosingPairs');
2538+
}
2539+
25362540
const handle = this._nextHandle();
25372541
const serializedConfiguration: extHostProtocol.ILanguageConfigurationDto = {
25382542
comments: configuration.comments,
@@ -2542,7 +2546,9 @@ export class ExtHostLanguageFeatures implements extHostProtocol.ExtHostLanguageF
25422546
onEnterRules: configuration.onEnterRules ? ExtHostLanguageFeatures._serializeOnEnterRules(configuration.onEnterRules) : undefined,
25432547
__electricCharacterSupport: configuration.__electricCharacterSupport,
25442548
__characterPairSupport: configuration.__characterPairSupport,
2549+
autoClosingPairs: configuration.autoClosingPairs
25452550
};
2551+
25462552
this._proxy.$setLanguageConfiguration(handle, languageId, serializedConfiguration);
25472553
return this._createDisposable(handle);
25482554
}

src/vs/workbench/services/extensions/common/extensionsApiProposals.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ export const allApiProposals = Object.freeze({
5454
interactiveUserActions: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.interactiveUserActions.d.ts',
5555
interactiveWindow: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.interactiveWindow.d.ts',
5656
ipc: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.ipc.d.ts',
57+
languageConfigurationAutoClosingPairs: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.languageConfigurationAutoClosingPairs.d.ts',
5758
notebookCellExecutionState: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.notebookCellExecutionState.d.ts',
5859
notebookCodeActions: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.notebookCodeActions.d.ts',
5960
notebookControllerAffinityHidden: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.notebookControllerAffinityHidden.d.ts',
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
6+
declare module 'vscode' {
7+
8+
// https://github.com/microsoft/vscode/issues/173738
9+
10+
export interface LanguageConfiguration {
11+
autoClosingPairs?: {
12+
open: string;
13+
close: string;
14+
notIn?: string[];
15+
}[];
16+
}
17+
}

0 commit comments

Comments
 (0)