← 返回首页
`GoogleJavaFormatImportOptimizer`: re-run import format if `document.txt` has changed by facboy · Pull Request #971 · google/google-java-format · GitHub
Skip to content

Navigation Menu

Toggle navigation
Sign in
Appearance settings
Search or jump to...

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Include my email address so I can be contacted

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Resetting focus

GoogleJavaFormatImportOptimizer: re-run import format if document.txt has changed#971

Open
facboy wants to merge 1 commit into
google:masterfrom
facboy:master
Open

GoogleJavaFormatImportOptimizer: re-run import format if document.txt has changed#971
facboy wants to merge 1 commit into
google:masterfrom
facboy:master

Conversation

Copy link
Copy Markdown
Contributor

facboy commented Sep 15, 2023
edited
Loading

This is a follow up to #960 - occasionally the imports are left unformatted and it can be annoying.

…text` has changed If `document.text` has changed when trying to apply the changes, re-run the import format. This should fix occasional issues with imports not being ordered/formatted correctly after a format operation.
cushon requested a review from plumpy October 2, 2023 20:50
cushon added the IntelliJ label Oct 2, 2023
Copy link
Copy Markdown
Collaborator

plumpy commented Oct 9, 2023

Are you sure this is what's happening? Can you reproduce this?

My plan was that if we detected this case, I would re-trigger the ImportOptimizer, so it would call processFile again (off the Swing thread) and then call the returned runnable back on the Swing thread.

But as far as I can tell IntelliJ already handle that for us. What I see when I try to reproduce this is that IntelliJ is smart and basically if you run "optimize imports" and then change the file before it has a chance to call the returned runnable and make the edit, it knows the file changed, and it will throw that Runnable away and call processFile and start the whole process over again.

So I'm wondering if the behavior you're seeing has a different cause?

Copy link
Copy Markdown
Contributor Author

facboy commented Oct 9, 2023

it's pretty sporadic, i can revert back to the released version and see. anedoctally, i haven't seen it once since i fixed this locally.

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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.

3 participants

Footer

© 2026 GitHub, Inc.