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

Fix SwiftUI indentation issues #154

Merged
merged 4 commits into from
Feb 4, 2025
Merged

Conversation

ottijp
Copy link
Contributor

@ottijp ottijp commented Feb 2, 2025

Hi. Thank you for developing such useful plugin. It helps me everyday!

I fixed some issues with SwiftUI indentation. (includes issue #152)

View Modifiers

was:

NavigationStack {
    CoolView()
    .padding(10)
}
.padding(12)

now:

NavigationStack {
    CoolView()
        .padding(10)
}
.padding(12)

ViewBuilders

was:

VStack {
    Text("Hello, World!")
Button(action: { print("clicked") }) {
    Text("click me")
}
}

now:

VStack {
    Text("Hello, World!")
    Button(action: { print("clicked") }) {
        Text("click me")
    }
}

tests

  • I applied auto-indentation to example/example.swift and example/MainViewController.swift and confirmed that this change will cause no side effects.
  • I created new example file SwiftUIView.swift and confirmed that the indentation with this plugin and Xcode are same.

appendix

I fixed example/MainViewController.swift first because indentation of this file was not consistent with this plugin's indentation result.

@@ -54,13 +54,13 @@ class MainViewController: UIViewController, UITableViewDataSource {
self.tableView.reloadSections(NSIndexSet(index: 0), withRowAnimation: .Fade)
self.refreshControl.endRefreshing()
UIApplication.sharedApplication().networkActivityIndicatorVisible = false
})
})
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these seem like they're indenting incorrectly now?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for pointing this out.

I believe that this example should have been changed in PR #130 like this line.
I have verified that, with the latest commit on the master branch, the closing parentheses are now aligned with the opening parentheses.
This alignment was achieved after applying auto-indentation using this plugin.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops sorry!

@keith keith merged commit a899f26 into keith:master Feb 4, 2025
@keith
Copy link
Owner

keith commented Feb 4, 2025

thanks!

@ottijp ottijp deleted the fix-swiftui-indentation branch February 5, 2025 09:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants