google-java-format icon indicating copy to clipboard operation
google-java-format copied to clipboard

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

Open facboy opened this issue 2 years ago • 2 comments

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

facboy avatar Sep 15 '23 18:09 facboy

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?

plumpy avatar Oct 09 '23 03:10 plumpy

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.

facboy avatar Oct 09 '23 07:10 facboy