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) {
55
55
56
56
JavaFormatterOptions .Style style = GoogleJavaFormatSettings .getInstance (project ).getStyle ();
57
57
58
+ final String origText = document .getText ();
58
59
String text ;
59
60
try {
60
- text =
61
- ImportOrderer .reorderImports (
62
- RemoveUnusedImports .removeUnusedImports (document .getText ()), style );
61
+ text = ImportOrderer .reorderImports (RemoveUnusedImports .removeUnusedImports (origText ), style );
63
62
} catch (FormatterException e ) {
64
63
Notifications .displayParsingErrorNotification (project , file .getName ());
65
64
return Runnables .doNothing ();
66
65
}
67
66
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
+ };
69
77
}
70
78
}
You can’t perform that action at this time.
0 commit comments