1
>
/*---------------------------------------------------------------------------------------------
onEnter.ts
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
>
import { onUnexpectedError } from '../../../../base/common/errors.js';
7
>
import * as strings from '../../../../base/common/strings.js';
8
>
import { CharacterPair, EnterAction, IndentAction, OnEnterRule } from '../languageConfiguration.js';
9
>
import { EditorAutoIndentStrategy } from '../../config/editorOptions.js';
10
>
11
>
export interface IOnEnterSupportOptions {
12
>
brackets?: CharacterPair[];
13
>
onEnterRules?: OnEnterRule[];
14
>
}
15
>
16
>
interface IProcessedBracketPair {
17
>
open: string;
18
>
close: string;
19
>
openRegExp: RegExp;
20
>
closeRegExp: RegExp;
21
>
}
22
>
23
>
export class OnEnterSupport {
24
>
25
>
private readonly _brackets: IProcessedBracketPair[];
26
>
private readonly _regExpRules: OnEnterRule[];
27
>
28
>
constructor(opts: IOnEnterSupportOptions) {
29
opts = opts || {};
30
opts.brackets = opts.brackets || [