From 4dfc14b846a0c884d20dcfcdaf4d55b64dbbdfae Mon Sep 17 00:00:00 2001 From: Rhitik Bhatt Date: Mon, 15 Jun 2020 18:57:40 +0000 Subject: [PATCH] Fixes buggy onEnter behavior when used with generator method (#100076) * Adds regex to ignore already closed comment block * Adds test case for generator method onEnter buggy behavior --- .../src/features/languageConfiguration.ts | 2 +- .../editor/test/common/modes/supports/javascriptOnEnterRules.ts | 2 +- src/vs/editor/test/common/modes/supports/onEnter.test.ts | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/extensions/typescript-language-features/src/features/languageConfiguration.ts b/extensions/typescript-language-features/src/features/languageConfiguration.ts index 91cb4a36c91..e7f0af0ff9c 100644 --- a/extensions/typescript-language-features/src/features/languageConfiguration.ts +++ b/extensions/typescript-language-features/src/features/languageConfiguration.ts @@ -31,7 +31,7 @@ const jsTsLanguageConfiguration: vscode.LanguageConfiguration = { }, { // e.g. * ...| beforeText: /^(\t|[ ])*[ ]\*([ ]([^\*]|\*(?!\/))*)?$/, - oneLineAboveText: /^(\s*(\/\*\*|\*)).*/, + oneLineAboveText: /(?=^(\s*(\/\*\*|\*)).*)(?=(?!(\s*\*\/)))/, action: { indentAction: vscode.IndentAction.None, appendText: '* ' }, }, { // e.g. */| diff --git a/src/vs/editor/test/common/modes/supports/javascriptOnEnterRules.ts b/src/vs/editor/test/common/modes/supports/javascriptOnEnterRules.ts index 8ad60864350..7222048074e 100644 --- a/src/vs/editor/test/common/modes/supports/javascriptOnEnterRules.ts +++ b/src/vs/editor/test/common/modes/supports/javascriptOnEnterRules.ts @@ -18,7 +18,7 @@ export const javascriptOnEnterRules = [ }, { // e.g. * ...| beforeText: /^(\t|[ ])*[ ]\*([ ]([^\*]|\*(?!\/))*)?$/, - oneLineAboveText: /^(\s*(\/\*\*|\*)).*/, + oneLineAboveText: /(?=^(\s*(\/\*\*|\*)).*)(?=(?!(\s*\*\/)))/, action: { indentAction: IndentAction.None, appendText: '* ' } }, { // e.g. */| diff --git a/src/vs/editor/test/common/modes/supports/onEnter.test.ts b/src/vs/editor/test/common/modes/supports/onEnter.test.ts index 6fc397d62fe..f799c66e76e 100644 --- a/src/vs/editor/test/common/modes/supports/onEnter.test.ts +++ b/src/vs/editor/test/common/modes/supports/onEnter.test.ts @@ -118,6 +118,7 @@ suite('OnEnter', () => { testIndentAction(' *', ' * asdfsfagadfg * / * / * /*', '', IndentAction.None, '* '); testIndentAction('', ' */', '', IndentAction.None, null, 1); + testIndentAction(' */', ' * test() {', '', IndentAction.Indent, null, 0); testIndentAction('', '\t */', '', IndentAction.None, null, 1); testIndentAction('', '\t\t */', '', IndentAction.None, null, 1); testIndentAction('', ' */', '', IndentAction.None, null, 1);