-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
CSharpIndentationService simplification #76580
Open
jnm2
wants to merge
17
commits into
dotnet:main
Choose a base branch
from
jnm2:csharp_indentation_simplification
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
+126
−64
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In order for it to be respected, GetIndentationOfCurrentPosition has to obtain a non-relative IndentBlockOperation. But if you are inside a separated syntax list, the there will always be a relative IndentBlockOperation. (CSharpIndentationFormattingRule.AddIndentBlockOperations and IndentBlockFormattingRule.AddAlignmentBlockOperation see to this.)
…z" method originally
dotnet-issue-labeler
bot
added
Area-IDE
untriaged
Issues and PRs which have not yet been triaged by a lead
labels
Dec 29, 2024
dotnet-policy-service
bot
added
Community
The pull request was submitted by a contributor who is not a Microsoft employee.
VSCode
labels
Dec 29, 2024
...aredUtilitiesAndExtensions/Workspace/CSharp/Indentation/CSharpIndentationService.Indenter.cs
Outdated
Show resolved
Hide resolved
jnm2
force-pushed
the
csharp_indentation_simplification
branch
from
December 29, 2024 23:51
aded4de
to
9184234
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
While looking into #38057, with some interest in sharing smart indent logic so that the formatter can use it when it formats elastic whitespace, I did some simplification in CSharpIndentationService.
Methods that handle specific situations no longer decide what's next to try, if the situation they are responsible for does not apply. "What's next" is decided in one method now. There's no GetDefaultIndentation that can be independently called from elsewhere.
As a result, I found and fixed two smart indent bugs (see the added unit tests).
Another special case was also removed, deciding not to add an additional increment of indentation when inside a separated syntax list, since that decision is always ignored when inside a separated syntax list. This special case dates back to the initial commit in this repo. More details are in the commit message where this was done.