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

onEnterRules should be multi-line aware #50952

Open
kghose opened this issue Jun 1, 2018 · 2 comments
Open

onEnterRules should be multi-line aware #50952

kghose opened this issue Jun 1, 2018 · 2 comments
Assignees
Labels
editor-autoindent Editor auto indentation issues feature-request Request for new features or functionality languages-basic Basic language support issues

Comments

@kghose
Copy link

kghose commented Jun 1, 2018

Use case: microsoft/vscode-cpptools#2072
Steps to Reproduce:

Type the following text in a .cpp file

a = a
    * b;

Then hit enter at the end of the line to begin a new line. You'll get

a = a
    * b;
    * 

This is not expected behavior in this context. This is perhaps expected when in the middle of a multiline decorated comment but not otherwise.

This does not happen in an unsaved file, a file with no extension, .txt extension etc. and does not happen if the cpptools extension is disabled and happens when it is re-enabled.

@vscodebot vscodebot bot added editor editor-core Editor basic functionality labels Jun 1, 2018
@aeschli
Copy link
Contributor

aeschli commented Jun 4, 2018

The CPP extension sets onEnterRules like TypeScript:

onEnterRules: [
		{
			// e.g. /** | */
			beforeText: /^\s*\/\*\*(?!\/)([^\*]|\*(?!\/))*$/,
			afterText: /^\s*\*\/$/,
			action: { indentAction: IndentAction.IndentOutdent, appendText: ' * ' }
		}, {
			// e.g. /** ...|
			beforeText: /^\s*\/\*\*(?!\/)([^\*]|\*(?!\/))*$/,
			action: { indentAction: IndentAction.None, appendText: ' * ' }
		}, {
			// e.g.  * ...|
			beforeText: /^(\t|[ ])*[ ]\*([ ]([^\*]|\*(?!\/))*)?$/,
			action: { indentAction: IndentAction.None, appendText: '* ' }
		}, 

Looks like the last rule matches here and causes the observed behavior.

@aeschli aeschli changed the title Regexp should be multi-line aware onEnterRules should be multi-line aware Jun 4, 2018
@aeschli aeschli assigned rebornix and unassigned aeschli Jun 4, 2018
@rebornix rebornix added bug Issue identified by VS Code Team member as probable bug languages-basic Basic language support issues and removed editor-core Editor basic functionality labels Jun 4, 2018
@bobbrow
Copy link
Member

bobbrow commented Jul 20, 2018

The user wants to keep the last rule when inside a multiline comment, but from what I understand the beforeText can only match a single line, so it appears that there's no way for us to write a rule that can detect whether we're in a multiline comment or not (e.g. by looking at the previous line).

@rebornix rebornix added editor-autoindent Editor auto indentation issues and removed editor labels Sep 18, 2018
@rebornix rebornix added feature-request Request for new features or functionality and removed bug Issue identified by VS Code Team member as probable bug labels Nov 3, 2020
@aiday-mar aiday-mar added the c++ C++ support issues label Mar 15, 2024
@aiday-mar aiday-mar assigned aiday-mar and unassigned rebornix Mar 15, 2024
@aiday-mar aiday-mar removed the c++ C++ support issues label Mar 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
editor-autoindent Editor auto indentation issues feature-request Request for new features or functionality languages-basic Basic language support issues
Projects
None yet
Development

No branches or pull requests

5 participants