Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add proposed api to support auto closing pairs on langauge configuration #186567

Merged
merged 8 commits into from
Jul 14, 2023
4 changes: 3 additions & 1 deletion src/vs/workbench/api/browser/mainThreadLanguageFeatures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -852,7 +852,9 @@ export class MainThreadLanguageFeatures extends Disposable implements MainThread
__electricCharacterSupport: undefined
};

if (_configuration.__characterPairSupport) {
if (_configuration.autoClosingPairs) {
configuration.autoClosingPairs = _configuration.autoClosingPairs;
} else if (_configuration.__characterPairSupport) {
// backwards compatibility
configuration.autoClosingPairs = _configuration.__characterPairSupport.autoClosingPairs;
}
Expand Down
5 changes: 5 additions & 0 deletions src/vs/workbench/api/common/extHost.protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,11 @@ export interface ILanguageConfigurationDto {
notIn?: string[];
}[];
};
autoClosingPairs?: {
open: string;
close: string;
notIn?: string[];
}[];
}

export type GlobPattern = string | IRelativePattern;
Expand Down
6 changes: 6 additions & 0 deletions src/vs/workbench/api/common/extHostLanguageFeatures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2533,6 +2533,10 @@ export class ExtHostLanguageFeatures implements extHostProtocol.ExtHostLanguageF
`Do not use.`);
}

if (configuration.autoClosingPairs) {
checkProposedApiEnabled(extension, 'languageConfigurationAutoClosingPairs');
}

const handle = this._nextHandle();
const serializedConfiguration: extHostProtocol.ILanguageConfigurationDto = {
comments: configuration.comments,
Expand All @@ -2542,7 +2546,9 @@ export class ExtHostLanguageFeatures implements extHostProtocol.ExtHostLanguageF
onEnterRules: configuration.onEnterRules ? ExtHostLanguageFeatures._serializeOnEnterRules(configuration.onEnterRules) : undefined,
__electricCharacterSupport: configuration.__electricCharacterSupport,
__characterPairSupport: configuration.__characterPairSupport,
autoClosingPairs: configuration.autoClosingPairs
alexdima marked this conversation as resolved.
Show resolved Hide resolved
};

this._proxy.$setLanguageConfiguration(handle, languageId, serializedConfiguration);
return this._createDisposable(handle);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export const allApiProposals = Object.freeze({
interactiveUserActions: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.interactiveUserActions.d.ts',
interactiveWindow: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.interactiveWindow.d.ts',
ipc: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.ipc.d.ts',
languageConfigurationAutoClosingPairs: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.languageConfigurationAutoClosingPairs.d.ts',
notebookCellExecutionState: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.notebookCellExecutionState.d.ts',
notebookCodeActions: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.notebookCodeActions.d.ts',
notebookControllerAffinityHidden: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.notebookControllerAffinityHidden.d.ts',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

declare module 'vscode' {

// https://github.com/microsoft/vscode/issues/173738

export interface LanguageConfiguration {
autoClosingPairs?: {
open: string;
close: string;
notIn?: string[];
}[];
}
}