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

feat: org imports on format #793

Merged
merged 11 commits into from
Jun 22, 2024
Merged

feat: org imports on format #793

merged 11 commits into from
Jun 22, 2024

Conversation

joerdav
Copy link
Collaborator

@joerdav joerdav commented Jun 14, 2024

No description provided.

@joerdav joerdav changed the title feat: WIP attemt org imports when formatting with a file name feat: org imports on format Jun 17, 2024
@joerdav joerdav force-pushed the organise-imports branch from 84cd57c to b9837aa Compare June 17, 2024 10:53
@joerdav joerdav marked this pull request as ready for review June 17, 2024 10:53
@joerdav joerdav force-pushed the organise-imports branch from b9837aa to d15ddbd Compare June 17, 2024 13:54
@joerdav joerdav requested a review from a-h June 17, 2024 15:02
@a-h
Copy link
Owner

a-h commented Jun 18, 2024

Looking good! I'll give it a proper review when I can. Thanks so much for this, it's such a cool feature.

@joerdav
Copy link
Collaborator Author

joerdav commented Jun 18, 2024

No problem! Let me know if you have questions about the code, or any changes for me to make.

Copy link
Owner

@a-h a-h left a comment

Choose a reason for hiding this comment

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

Just a minor naming thing, I'll pick it up. Thanks!

// Generate code.
gw := bytes.NewBuffer(nil)
var updatedImports []*ast.ImportSpec
var eg errgroup.Group
Copy link
Owner

Choose a reason for hiding this comment

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

TIL about errgroup...

// var templ_7745c5c3_CSSBuilder strings.Builder
if _, err = g.w.WriteIndent(indentLevel, "var templ_7745c5c3_CSSBuilder strings.Builder\n"); err != nil {
// templ_7745c5c3_CSSBuilder, _, release := templruntime.WriterToBuffer(nil)
if _, err = g.w.WriteIndent(indentLevel, "templ_7745c5c3_CSSBuilder, _, release := templruntime.WriterToBuffer(nil)\n"); err != nil {
Copy link
Owner

Choose a reason for hiding this comment

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

I think release should be called templ_7745c5c3_release.

if _, err = g.w.WriteIndent(indentLevel, "templ_7745c5c3_CSSBuilder, _, release := templruntime.WriterToBuffer(nil)\n"); err != nil {
return err
}
if _, err = g.w.WriteIndent(indentLevel, "defer release()\n"); err != nil {
Copy link
Owner

Choose a reason for hiding this comment

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

As per above... templ_7745c5c3_release()

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