Skip to content

Prevent edit if nothing was formatted #120

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

Merged
merged 3 commits into from
Feb 9, 2017
Merged

Prevent edit if nothing was formatted #120

merged 3 commits into from
Feb 9, 2017

Conversation

sormuras
Copy link
Contributor

@sormuras sormuras commented Feb 9, 2017

Handle trivial cases, where input equals output, to prevent dirty flags in active editors.

Handle trivial cases, where input equals output, to prevent dirty flags in active editors.
@cushon
Copy link
Collaborator

cushon commented Feb 9, 2017

This looks ok. Can you elaborate on the problem it solves? Is it related to #119?

@sormuras
Copy link
Contributor Author

sormuras commented Feb 9, 2017

It was discovered while trying to reproduce the problem described in #119 -- not related.

When you format an entire file (or section) once and save it, a subsequent format should not change the text. Idempotency like ensured by https://github.com/google/google-java-format/blob/master/core/src/test/java/com/google/googlejavaformat/java/FormatterIntegrationTest.java#L101

The current implementation replaces the old text with new text, even when they are equal, and that marks the active editor as dirty.

@sormuras
Copy link
Contributor Author

sormuras commented Feb 9, 2017

#105 and #106 are related. In a console-y way. 😉

Handle trivial cases, where input equals output, to prevent dirty flags in active editors.
@sormuras
Copy link
Contributor Author

sormuras commented Feb 9, 2017

Just give me another second, moving the new code into its own method.

Handle trivial cases, where input equals output, to prevent dirty flags in active editors.
@davido
Copy link

davido commented Feb 9, 2017

Oh, I see this problem, now that the plugi was fixed to work against Gerrit project. After pressing Ctrl-Shift+F without changes, the file is markes durty, and asterisk appear in fron of the file name.

@cushon cushon merged commit 34e9581 into google:master Feb 9, 2017
@davido
Copy link

davido commented Feb 9, 2017

@sormuras

With this CL applied, the plugin works as expected. There is no difference between Ctrl+Shift+F in Eclipse and gjf invocation from the command line. That's really really great. Thank you so much.

@cushon
Can we release new gjf version including the plugin binary ASAP? 1.2.1 or even 1.3, now that we have Eclipse plugin?

@cushon
Copy link
Collaborator

cushon commented Feb 9, 2017

Sure, what's the best way to release this? I don't know how eclipse plugins are distributed. Would being able to download it from the github release page be a useful place to start?

@davido
Copy link

davido commented Feb 9, 2017

Would being able to download it from the github release page be a useful place to start?

That would be cool! I volunteer to upload change to Gerrit with instructions, how to deploy it and write announcement on the repo-discuss mailing list. Thank you again for your help!

@sormuras
Copy link
Contributor Author

You're welcome!

@sormuras sormuras deleted the eclispe_keep_original branch February 10, 2017 04:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants