|
1 | 1 | package net.seesharpsoft.intellij.plugins.csv.psi; |
2 | 2 |
|
3 | 3 | import com.intellij.openapi.application.ApplicationManager; |
| 4 | +import com.intellij.openapi.application.WriteAction; |
4 | 5 | import com.intellij.openapi.command.CommandProcessor; |
5 | 6 | import com.intellij.openapi.editor.Document; |
6 | 7 | import com.intellij.openapi.fileTypes.FileType; |
@@ -515,27 +516,25 @@ private static class DocumentPsiAction extends PsiAction { |
515 | 516 |
|
516 | 517 | @Override |
517 | 518 | public void execute() { |
518 | | - ApplicationManager.getApplication().runWriteAction( |
519 | | - () -> { |
520 | | - PsiFile psiFile = (PsiFile) getAnchor(); |
| 519 | + WriteAction.run(() -> { |
| 520 | + PsiFile psiFile = (PsiFile) getAnchor(); |
521 | 521 |
|
522 | | - PsiDocumentManager manager = PsiDocumentManager.getInstance(psiFile.getProject()); |
523 | | - Document document = manager.getDocument(psiFile); |
524 | | - if (document == null) return; |
| 522 | + PsiDocumentManager manager = PsiDocumentManager.getInstance(psiFile.getProject()); |
| 523 | + Document document = manager.getDocument(psiFile); |
| 524 | + if (document == null) return; |
525 | 525 |
|
526 | | - manager.doPostponedOperationsAndUnblockDocument(document); |
| 526 | + manager.doPostponedOperationsAndUnblockDocument(document); |
527 | 527 |
|
528 | | - int offset = 0; |
529 | | - for (Pair<TextRange, String> replacement : myReplacements) { |
530 | | - TextRange textRange = replacement.getFirst().shiftRight(offset); |
531 | | - String text = replacement.getSecond(); |
532 | | - document.replaceString(textRange.getStartOffset(), textRange.getEndOffset(), text); |
533 | | - offset += text.length() - textRange.getLength(); |
534 | | - } |
| 528 | + int offset = 0; |
| 529 | + for (Pair<TextRange, String> replacement : myReplacements) { |
| 530 | + TextRange textRange = replacement.getFirst().shiftRight(offset); |
| 531 | + String text = replacement.getSecond(); |
| 532 | + document.replaceString(textRange.getStartOffset(), textRange.getEndOffset(), text); |
| 533 | + offset += text.length() - textRange.getLength(); |
| 534 | + } |
535 | 535 |
|
536 | | - manager.commitDocument(document); |
537 | | - } |
538 | | - ); |
| 536 | + manager.commitDocument(document); |
| 537 | + }); |
539 | 538 | } |
540 | 539 | } |
541 | 540 | } |
0 commit comments