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

Add support for previous line patterns in the indentation rules #209804

Open
aiday-mar opened this issue Apr 8, 2024 · 1 comment
Open

Add support for previous line patterns in the indentation rules #209804

aiday-mar opened this issue Apr 8, 2024 · 1 comment
Assignees
Labels
editor-autoindent Editor auto indentation issues feature-request Request for new features or functionality

Comments

@aiday-mar
Copy link
Contributor

aiday-mar commented Apr 8, 2024

This feature request is derived from #43244 (comment). Currently when Enter is typed after a braceless if statement, the next line is indented as follows:

if (true)
....

Some users in the thread mentioned that after typing {} on that line, they want the code to be unindented at that position as follows:

if (true)
{}

We have the unIndentedLinePattern which we could use to solve this, that is we could unindent when the pair {} is encountered on a line. This however would cause issues generally, like in the following case:

{
     a: {}
}

Here we do not want to decrease the indentation on typing the {} after the field name a. To mitigate this, we may want the indentation rules to support regex rules on the previous line. That is, we may want to have the following syntax in the language configuration file:

unIndentedLinePattern: {
    currentLinePattern: Regex;
    previousLinePattern: Regex;
}

In this way, the new syntax would ressemble more the syntax for the onEnter indentation rules.

@aiday-mar aiday-mar self-assigned this Apr 8, 2024
@aiday-mar aiday-mar added editor-autoindent Editor auto indentation issues feature-request Request for new features or functionality labels Apr 8, 2024
@aiday-mar aiday-mar changed the title Allow indentation rules to add support for previous line patterns Add support for previous line patterns in the indentation rules Apr 8, 2024
@aiday-mar
Copy link
Contributor Author

After discussion with the team, we have come to the conclusion that we do not want to increase the complexity of the language configuration file as of yet. The above proposition suggests adding more fields to the language configuration file which we currently do not want.

In the meantime to solve the issue put forth, please see #209822

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
Projects
None yet
Development

No branches or pull requests

1 participant