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

chore: better format defaults #45

Merged
merged 1 commit into from Sep 13, 2022
Merged

Conversation

longkai
Copy link
Contributor

@longkai longkai commented Sep 11, 2022

Now I bundle the binary as a vscode extension. I use the stdin method to do the job and set the editor settings formatOnSave true. Each time saving the file, the format result will always insert a new line at the end, which is annoying.

So, this PR:

  • don't append new line at the end and keep the content as it is
  • default retain line breaks for readability since format itself is all about readability

LineEnding: lineBreakStyle,
Indent: 2,
LineEnding: lineBreakStyle,
RetainLineBreaks: true,
Copy link
Collaborator

Choose a reason for hiding this comment

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

My rule has been that if there's a feature that has to hack around a shortcoming of the yaml library, I have it turned off by default to make the most stable possible default experience (despite weird behaviours from the library).

Does the vscode extension not read from the working directory's .yamlfmt or accept options from settings.json?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, it's fine. I suppose everybody needs the feature and I could make it default in vscode.

@@ -122,7 +122,7 @@ func RunCommand(
if err != nil {
return err
}
fmt.Println(string(out))
fmt.Print(string(out))
Copy link
Collaborator

Choose a reason for hiding this comment

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

That's a good idea, I didn't think of that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So, how about this PR only changes this line 😅

Copy link
Collaborator

Choose a reason for hiding this comment

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

That would be fine with me!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK. it's done.

Each time saving the file, the format result will always insert a new line at the end, which is annoying.
@braydonk braydonk merged commit d9d4189 into google:main Sep 13, 2022
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.

None yet

2 participants