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

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

facboy
Copy link
Contributor

@facboy facboy commented Sep 15, 2023

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 cushon requested a review from plumpy October 2, 2023 20:50
@cushon cushon added the IntelliJ label Oct 2, 2023
@plumpy
Copy link
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?

@facboy
Copy link
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.

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