File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed
idea_plugin/src/main/java/com/google/googlejavaformat/intellij Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -55,16 +55,24 @@ public boolean supports(@NotNull PsiFile file) {
5555
5656 JavaFormatterOptions .Style style = GoogleJavaFormatSettings .getInstance (project ).getStyle ();
5757
58+ final String origText = document .getText ();
5859 String text ;
5960 try {
60- text =
61- ImportOrderer .reorderImports (
62- RemoveUnusedImports .removeUnusedImports (document .getText ()), style );
61+ text = ImportOrderer .reorderImports (RemoveUnusedImports .removeUnusedImports (origText ), style );
6362 } catch (FormatterException e ) {
6463 Notifications .displayParsingErrorNotification (project , file .getName ());
6564 return Runnables .doNothing ();
6665 }
6766
68- return () -> document .setText (text );
67+ return () -> {
68+ if (documentManager .isDocumentBlockedByPsi (document )) {
69+ documentManager .doPostponedOperationsAndUnblockDocument (document );
70+ String newText = document .getText ();
71+ if (!newText .equals (origText )) {
72+ return ;
73+ }
74+ }
75+ document .setText (text );
76+ };
6977 }
7078}
You can’t perform that action at this time.
0 commit comments