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

Handle OnEnterRule patterns #12228

Merged
merged 2 commits into from
Feb 27, 2023
Merged
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
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,7 @@
"eclipse-theia.builtin-extension-pack": "https://open-vsx.org/api/eclipse-theia/builtin-extension-pack/1.66.2/file/eclipse-theia.builtin-extension-pack-1.66.2.vsix",
"EditorConfig.EditorConfig": "https://open-vsx.org/api/EditorConfig/EditorConfig/0.14.4/file/EditorConfig.EditorConfig-0.14.4.vsix",
"dbaeumer.vscode-eslint": "https://open-vsx.org/api/dbaeumer/vscode-eslint/2.1.20/file/dbaeumer.vscode-eslint-2.1.20.vsix",
"ms-vscode.references-view": "https://open-vsx.org/api/ms-vscode/references-view/0.0.89/file/ms-vscode.references-view-0.0.89.vsix",
"vscode.typescript": "https://open-vsx.org/api/vscode/typescript/1.62.3/file/vscode.typescript-1.62.3.vsix",
"vscode.typescript-language-features": "https://open-vsx.org/api/vscode/typescript-language-features/1.62.3/file/vscode.typescript-language-features-1.62.3.vsix"
"ms-vscode.references-view": "https://open-vsx.org/api/ms-vscode/references-view/0.0.89/file/ms-vscode.references-view-0.0.89.vsix"
},
"theiaPluginsExcludeIds": [
"ms-vscode.js-debug-companion",
Expand Down
25 changes: 15 additions & 10 deletions packages/plugin-ext/src/common/plugin-protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -669,14 +669,19 @@ export interface LanguageContribution {
configuration?: LanguageConfiguration;
}

export interface RegExpOptions {
pattern: string;
flags?: string;
}

export interface LanguageConfiguration {
brackets?: CharacterPair[];
indentationRules?: IndentationRules;
surroundingPairs?: AutoClosingPair[];
autoClosingPairs?: AutoClosingPairConditional[];
comments?: CommentRule;
folding?: FoldingRules;
wordPattern?: string;
wordPattern?: string | RegExpOptions;
onEnterRules?: OnEnterRule[];
}

Expand All @@ -702,10 +707,10 @@ export interface DebuggerContribution extends PlatformSpecificAdapterContributio
}

export interface IndentationRules {
increaseIndentPattern: string;
decreaseIndentPattern: string;
unIndentedLinePattern?: string;
indentNextLinePattern?: string;
increaseIndentPattern: string | RegExpOptions;
decreaseIndentPattern: string | RegExpOptions;
unIndentedLinePattern?: string | RegExpOptions;
indentNextLinePattern?: string | RegExpOptions;
}
export interface AutoClosingPair {
close: string;
Expand All @@ -717,8 +722,8 @@ export interface AutoClosingPairConditional extends AutoClosingPair {
}

export interface FoldingMarkers {
start: string;
end: string;
start: string | RegExpOptions;
end: string | RegExpOptions;
}

export interface FoldingRules {
Expand All @@ -727,9 +732,9 @@ export interface FoldingRules {
}

export interface OnEnterRule {
beforeText: string;
afterText?: string;
previousLineText?: string;
beforeText: string | RegExpOptions;
afterText?: string | RegExpOptions;
previousLineText?: string | RegExpOptions;
action: EnterAction;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { TextmateRegistry, getEncodedLanguageId, MonacoTextmateService, GrammarD
import { MenusContributionPointHandler } from './menus/menus-contribution-handler';
import { PluginViewRegistry } from './view/plugin-view-registry';
import { PluginCustomEditorRegistry } from './custom-editors/plugin-custom-editor-registry';
import { PluginContribution, IndentationRules, FoldingRules, ScopeMap, DeployedPlugin, GrammarsContribution, EnterAction, OnEnterRule } from '../../common';
import { PluginContribution, IndentationRules, FoldingRules, ScopeMap, DeployedPlugin, GrammarsContribution, EnterAction, OnEnterRule, RegExpOptions } from '../../common';
import {
DefaultUriLabelProviderContribution,
LabelProviderContribution,
Expand Down Expand Up @@ -488,11 +488,14 @@ export class PluginContributionHandler {
return Disposable.NULL;
}

private createRegex(value: string | undefined): RegExp | undefined {
private createRegex(value: string | RegExpOptions | undefined): RegExp | undefined {
if (typeof value === 'string') {
return new RegExp(value, '');
}
return undefined;
if (typeof value == 'undefined') {
return undefined;
}
return new RegExp(value.pattern, value.flags);
}

private convertIndentationRules(rules?: IndentationRules): monaco.languages.IndentationRule | undefined {
Expand Down