-
Notifications
You must be signed in to change notification settings - Fork 37.3k
Fix indentation rules for VB #286341
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
base: main
Are you sure you want to change the base?
Fix indentation rules for VB #286341
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes Visual Basic indentation issues by refining the indent/dedent patterns and adding explicit onEnter rules. The changes ensure proper automatic indentation when typing block keywords (like Sub, Module, If...Then) and dedenting when typing block terminators (like End Sub, End If, Loop).
Key changes:
- Updated
increaseIndentPatternregex to properly handle If/ElseIf...Then statements and ensure both alternatives are correctly anchored - Added
vbOnEnterRulesto prevent unintended indentation after End statements and block terminators - Removed overly broad onEnterRule that was incorrectly preventing indentation after lines ending with parentheses
- Added comprehensive test coverage for Module, Sub, Function, Class, If/ElseIf/Else, While, For, Do/Loop, Select/Case, and Try/Catch/Finally blocks
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/vs/editor/test/common/modes/supports/onEnterRules.ts |
Exports new vbOnEnterRules array with pattern to prevent indentation after block terminators |
src/vs/editor/test/common/modes/supports/indentationRules.ts |
Refactors increaseIndentPattern for VB to properly group alternatives and fix negative lookahead for single-line constructs |
src/vs/editor/contrib/indentation/test/browser/indentation.test.ts |
Imports vbOnEnterRules, registers it for VB language, and adds 18 new test cases covering various indentation scenarios |
extensions/vb/language-configuration.json |
Updates indentation patterns to match test configuration and removes problematic onEnterRule for closing parentheses |
Fixes #118932
Added more tests as well to cover onEnter scenarios.