Skip to content

Commit

Permalink
vscode: Support OnEnterRule#previousLineText
Browse files Browse the repository at this point in the history
Fixes #11131

Contributed on behalf of STMicroelectronics

Change-Id: Ieff708dedac5bcb9c387eccf6c58dffabb2b455f
Signed-off-by: Philip Langer <[email protected]>
  • Loading branch information
planger authored and martin-fleck-at committed Jun 7, 2022
1 parent 677c90e commit cc06ad8
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions packages/plugin-ext/src/common/plugin-api-rpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1316,6 +1316,7 @@ export interface EnterAction {
export interface SerializedOnEnterRule {
beforeText: SerializedRegExp;
afterText?: SerializedRegExp;
previousLineText?: SerializedRegExp;
action: EnterAction;
}

Expand Down
3 changes: 2 additions & 1 deletion packages/plugin-ext/src/main/browser/languages-main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1075,7 +1075,8 @@ function reviveOnEnterRule(onEnterRule: SerializedOnEnterRule): monaco.languages
return {
beforeText: reviveRegExp(onEnterRule.beforeText)!,
afterText: reviveRegExp(onEnterRule.afterText),
action: onEnterRule.action
previousLineText: reviveRegExp(onEnterRule.previousLineText),
action: onEnterRule.action,
};
}

Expand Down
5 changes: 3 additions & 2 deletions packages/plugin-ext/src/plugin/languages-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ export function serializeEnterRules(rules?: theia.OnEnterRule[]): SerializedOnEn

return rules.map(r =>
({
action: r.action,
beforeText: serializeRegExp(r.beforeText),
afterText: serializeRegExp(r.afterText)
afterText: serializeRegExp(r.afterText),
previousLineText: serializeRegExp(r.previousLineText),
action: r.action,
} as SerializedOnEnterRule));
}

Expand Down
4 changes: 4 additions & 0 deletions packages/plugin/src/theia.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6709,6 +6709,10 @@ export module '@theia/plugin' {
* This rule will only execute if the text after the cursor matches this regular expression.
*/
afterText?: RegExp;
/**
* This rule will only execute if the text above the current line matches this regular expression.
*/
previousLineText?: RegExp;
/**
* The action to execute.
*/
Expand Down

0 comments on commit cc06ad8

Please sign in to comment.