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 1 commit
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
11 changes: 8 additions & 3 deletions packages/plugin-ext/src/common/plugin-protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -726,10 +726,15 @@ export interface FoldingRules {
markers?: FoldingMarkers;
}

export interface OnEnterRuleRegExp {
pattern: string;
flags?: string;
}
colin-grant-work marked this conversation as resolved.
Show resolved Hide resolved

export interface OnEnterRule {
beforeText: string;
afterText?: string;
previousLineText?: string;
beforeText: string | OnEnterRuleRegExp;
afterText?: string | OnEnterRuleRegExp;
previousLineText?: string | OnEnterRuleRegExp;
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, OnEnterRuleRegExp } 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 | OnEnterRuleRegExp | 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