Skip to content

Commit

Permalink
AddConditionalToSurroundingPairs2
Browse files Browse the repository at this point in the history
That's is needed so that we are no able to select a part of a string (which is already surrounded by quotes) and surround it by other chars, like sharp for example. We want the selected string to be replaced and not surrounded.
  • Loading branch information
OS-liviaschneider committed Apr 28, 2023
1 parent 75e0085 commit 766271c
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 7 deletions.
2 changes: 1 addition & 1 deletion build/monaco/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "monaco-editor-core",
"private": true,
"version": "0.31.1-os",
"version": "0.31.1-os2-cnh-1",
"description": "A browser based code editor",
"author": "Microsoft Corporation",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion src/vs/editor/common/modes/languageConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export interface LanguageConfiguration {
* selected string is surrounded by the open and close characters. If not set, the autoclosing pairs
* settings will be used.
*/
surroundingPairs?: IAutoClosingPair[];
surroundingPairs?: IAutoClosingPairConditional[];
/**
* Defines a list of bracket pairs that are colorized depending on their nesting level.
* If not set, the configured brackets will be used.
Expand Down
15 changes: 13 additions & 2 deletions src/vs/editor/common/modes/languageConfigurationRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,18 @@ import { LineTokens } from 'vs/editor/common/core/lineTokens';
import { Range } from 'vs/editor/common/core/range';
import { ITextModel } from 'vs/editor/common/model';
import { DEFAULT_WORD_REGEXP, ensureValidWordDefinition } from 'vs/editor/common/model/wordHelper';
import { EnterAction, FoldingRules, IAutoClosingPair, IndentAction, IndentationRule, LanguageConfiguration, CompleteEnterAction, AutoClosingPairs, CharacterPair, ExplicitLanguageConfiguration } from 'vs/editor/common/modes/languageConfiguration';
import {
EnterAction,
FoldingRules,
IndentAction,
IndentationRule,
LanguageConfiguration,
CompleteEnterAction,
AutoClosingPairs,
CharacterPair,
ExplicitLanguageConfiguration,
IAutoClosingPairConditional
} from 'vs/editor/common/modes/languageConfiguration';
import { createScopedLineTokens, ScopedLineTokens } from 'vs/editor/common/modes/supports';
import { CharacterPairSupport } from 'vs/editor/common/modes/supports/characterPair';
import { BracketElectricCharacterSupport, IElectricAction } from 'vs/editor/common/modes/supports/electricCharacter';
Expand Down Expand Up @@ -272,7 +283,7 @@ export class LanguageConfigurationRegistryImpl {
return characterPairSupport.getAutoCloseBeforeSet();
}

public getSurroundingPairs(languageId: string): IAutoClosingPair[] {
public getSurroundingPairs(languageId: string): IAutoClosingPairConditional[] {
let characterPairSupport = this._getCharacterPairSupport(languageId);
if (!characterPairSupport) {
return [];
Expand Down
11 changes: 8 additions & 3 deletions src/vs/editor/common/modes/supports/characterPair.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,20 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { IAutoClosingPair, StandardAutoClosingPairConditional, LanguageConfiguration, CharacterPair } from 'vs/editor/common/modes/languageConfiguration';
import {
StandardAutoClosingPairConditional,
LanguageConfiguration,
CharacterPair,
IAutoClosingPairConditional
} from 'vs/editor/common/modes/languageConfiguration';

export class CharacterPairSupport {

static readonly DEFAULT_AUTOCLOSE_BEFORE_LANGUAGE_DEFINED = ';:.,=}])> \n\t';
static readonly DEFAULT_AUTOCLOSE_BEFORE_WHITESPACE = ' \n\t';

private readonly _autoClosingPairs: StandardAutoClosingPairConditional[];
private readonly _surroundingPairs: IAutoClosingPair[];
private readonly _surroundingPairs: IAutoClosingPairConditional[];
private readonly _autoCloseBefore: string;
private readonly _colorizedBracketPairs: CharacterPair[];

Expand Down Expand Up @@ -57,7 +62,7 @@ export class CharacterPairSupport {
return this._autoCloseBefore;
}

public getSurroundingPairs(): IAutoClosingPair[] {
public getSurroundingPairs(): IAutoClosingPairConditional[] {
return this._surroundingPairs;
}

Expand Down

0 comments on commit 766271c

Please sign in to comment.