Fix SwiftUI view indentation after the ViewModifier block #158
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.
I found the issue that the line, which is placed after the ViewModifier (the line starting with
.
), won't be unshifted.This is caused by less consideration in PR #154 (sorry).
The indentation rule of Xcode is pretty complex.
If the line should be unshifted or not is depending on not only just previous line.
We also have to analyze if the previous lines are "dot block" (the previous line is included in the block staring with dot line (e.g. ViewModifier)).
So I created some helper functions.
s:CursorToBlockStart
s:SearchBackwardLineOrBlock
s:IsMatchingLineOrBlock
If you know more smart implementation, please tell me.
I also added some line to
example/SwiftUIView.swift
to test this change.I also refactored the cursor restoration method of function added in previous PR to align it with new functions.
Was:
Now:
Diff: