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

AddConditionalToSurroundingPairs2 #22

Draft
wants to merge 4 commits into
base: main-os
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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-3",
Copy link
Collaborator

@os-lmo os-lmo May 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't understand this versioning. According the rules it should be 0.31.1-os1, right?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, @os-lmo ...it has been a long time since I've done this PR. So, I need some time to switch and look at it again. That version was a temporary change in order to test. Of course the final version would follow the rules.

"description": "A browser based code editor",
"author": "Microsoft Corporation",
"license": "MIT",
Expand Down
4 changes: 2 additions & 2 deletions src/vs/editor/common/controller/cursorCommon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { ISelection, Selection } from 'vs/editor/common/core/selection';
import { ICommand, IConfiguration } from 'vs/editor/common/editorCommon';
import { ITextModel, PositionAffinity, TextModelResolvedOptions } from 'vs/editor/common/model';
import { TextModel } from 'vs/editor/common/model/textModel';
import { AutoClosingPairs, IAutoClosingPair } from 'vs/editor/common/modes/languageConfiguration';
import { AutoClosingPairs, IAutoClosingPairConditional } from 'vs/editor/common/modes/languageConfiguration';
import { LanguageConfigurationRegistry } from 'vs/editor/common/modes/languageConfigurationRegistry';
import { ICoordinatesConverter } from 'vs/editor/common/viewModel/viewModel';
export { CursorColumns } from './cursorColumns';
Expand Down Expand Up @@ -198,7 +198,7 @@ export class CursorConfiguration {
}
}

private static _getSurroundingPairs(languageId: string): IAutoClosingPair[] | null {
private static _getSurroundingPairs(languageId: string): IAutoClosingPairConditional[] | null {
try {
return LanguageConfigurationRegistry.getSurroundingPairs(languageId);
} catch (e) {
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[];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the original repo, this type was not changed - https://github.com/microsoft/vscode/blob/5a139d4ffc72fb8100c789bf2f67c09e5c33d05c/src/vs/editor/common/languages/languageConfiguration.ts#L64
Did you open any discussion or issue in the vscode main repo to discuss this change?

/**
* 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
2 changes: 1 addition & 1 deletion src/vs/monaco.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5583,7 +5583,7 @@ declare namespace monaco.languages {
* 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
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { ParseError, parse, getNodeType } from 'vs/base/common/json';
import { IJSONSchema } from 'vs/base/common/jsonSchema';
import * as types from 'vs/base/common/types';
import { URI } from 'vs/base/common/uri';
import { CharacterPair, CommentRule, EnterAction, ExplicitLanguageConfiguration, FoldingRules, IAutoClosingPair, IAutoClosingPairConditional, IndentAction, IndentationRule, OnEnterRule } from 'vs/editor/common/modes/languageConfiguration';
import { CharacterPair, CommentRule, EnterAction, ExplicitLanguageConfiguration, FoldingRules, IAutoClosingPairConditional, IndentAction, IndentationRule, OnEnterRule } from 'vs/editor/common/modes/languageConfiguration';
import { LanguageConfigurationRegistry } from 'vs/editor/common/modes/languageConfigurationRegistry';
import { IModeService } from 'vs/editor/common/services/modeService';
import { Extensions, IJSONContributionRegistry } from 'vs/platform/jsonschemas/common/jsonContributionRegistry';
Expand Down Expand Up @@ -47,7 +47,7 @@ interface ILanguageConfiguration {
comments?: CommentRule;
brackets?: CharacterPair[];
autoClosingPairs?: Array<CharacterPair | IAutoClosingPairConditional>;
surroundingPairs?: Array<CharacterPair | IAutoClosingPair>;
surroundingPairs?: Array<CharacterPair | IAutoClosingPairConditional>;
colorizedBracketPairs?: Array<CharacterPair>;
wordPattern?: string | IRegExp;
indentationRules?: IIndentationRules;
Expand Down Expand Up @@ -227,7 +227,7 @@ export class LanguageConfigurationFileHandler {
return result;
}

private _extractValidSurroundingPairs(languageId: string, configuration: ILanguageConfiguration): IAutoClosingPair[] | undefined {
private _extractValidSurroundingPairs(languageId: string, configuration: ILanguageConfiguration): IAutoClosingPairConditional[] | undefined {
const source = configuration.surroundingPairs;
if (typeof source === 'undefined') {
return undefined;
Expand All @@ -237,7 +237,7 @@ export class LanguageConfigurationFileHandler {
return undefined;
}

let result: IAutoClosingPair[] | undefined = undefined;
let result: IAutoClosingPairConditional[] | undefined = undefined;
for (let i = 0, len = source.length; i < len; i++) {
const pair = source[i];
if (Array.isArray(pair)) {
Expand All @@ -260,8 +260,14 @@ export class LanguageConfigurationFileHandler {
console.warn(`[${languageId}]: language configuration: expected \`surroundingPairs[${i}].close\` to be a string.`);
continue;
}
if (typeof pair.notIn !== 'undefined') {
if (!isStringArr(pair.notIn)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider merge both ifs

console.warn(`[${languageId}]: language configuration: expected \`autoClosingPairs[${i}].notIn\` to be a string array.`);
continue;
}
}
result = result || [];
result.push({ open: pair.open, close: pair.close });
result.push({ open: pair.open, close: pair.close, notIn: pair.notIn });
}
}
return result;
Expand Down