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

Test correct indentation when strings, comments, regex tokens contain brackets of language configuration #213561

Closed
2 tasks done
aiday-mar opened this issue May 27, 2024 · 0 comments

Comments

@aiday-mar
Copy link
Contributor

aiday-mar commented May 27, 2024

Refs: #209519, #209862

Complexity: 3

Create Issue


Indentation in the editor is determined by the indentation patterns of the language configuration file. There are 4 regex patterns called the increaseIndentPattern, decreaseIndentPattern, unIndentedLinePattern, indentNextLinePattern. If for example a line satisfies the increaseIndentPattern, then the line after will be indented (a similar logic applies for the other patterns).

It has been noticed that these patterns do not cover correctly all indentation logic. In particular for the following code:

const f = `(`

Previously if one would click on Enter after that line, the next line would be indented. This is because the line above satisfies the increaseIndentPattern pattern. To mitigate this (at least partially), this iteration we have worked on stripping the tokens of the current line of the brackets of the language configuration file before evaluating the indentation patterns. For the above example for example, the line would be stripped and would become:

const f = ``

The indentation patterns would be evaluated thereafter on that. Generally this is done for brackets appearing in string, comment or regex tokens.

To test the above, please follow the list below. VS Code has some inbuilt language configuration files, these are generally called language-configuration.json. The TypeScript language configuration file is at the following path: extensions/typescript-basics/language-configuration.json. You can find there the regex indentation patterns for TypeScript under indentationRules as well as the language brackets under brackets.

  1. Choose a programming language for which there is a language configuration file (either inbuilt or provided by an extension).
  2. Open a file and write some code containing a string. The string must contain some of the brackets of the language (defined in the configuration file)
  3. Press Enter after that line to trigger auto indentation and verify that the indentation level of the following lines is not affected by the brackets in the string (it could still be affected by the brackets outside of it). Generally verify that auto-indentation works correctly and no strange indentation happens.
  4. Follow steps 1 to 3 for brackets contained within a comment
  5. Follow steps 1 to 3 for brackets contained within a regex pattern
  6. Do the above for several languages

Thans for testing!

@vscodenpa vscodenpa added this to the May 2024 milestone May 27, 2024
@deepak1556 deepak1556 removed their assignment May 28, 2024
@digitarald digitarald removed their assignment May 29, 2024
@microsoft microsoft locked and limited conversation to collaborators Jul 13, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants