change line separators in a write action (IDEA-135914)
authorpeter <peter@jetbrains.com>
Tue, 3 Feb 2015 12:04:13 +0000 (13:04 +0100)
committerpeter <peter@jetbrains.com>
Tue, 3 Feb 2015 12:39:28 +0000 (13:39 +0100)
platform/editor-ui-ex/src/com/intellij/codeStyle/AbstractConvertLineSeparatorsAction.java

index 8f54a068385a73441a172fa03e8cbbf27b882462..c0541d66bd57039fdf39a8562fe6678e1fe4ea15 100644 (file)
@@ -16,7 +16,8 @@
 package com.intellij.codeStyle;
 
 import com.intellij.openapi.actionSystem.*;
-import com.intellij.openapi.command.CommandProcessor;
+import com.intellij.openapi.application.Result;
+import com.intellij.openapi.command.WriteCommandAction;
 import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.editor.Document;
 import com.intellij.openapi.fileEditor.FileDocumentManager;
@@ -34,8 +35,6 @@ import com.intellij.util.containers.Convertor;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
-import java.io.IOException;
-
 /**
  * @author Nikolai Matveev
  */
@@ -155,17 +154,11 @@ public abstract class AbstractConvertLineSeparatorsAction extends AnAction {
                                   LineSeparator.fromString(currentSeparator), LineSeparator.fromString(newSeparator));
     }
 
-    CommandProcessor commandProcessor = CommandProcessor.getInstance();
-    commandProcessor.executeCommand(project, new Runnable() {
+    new WriteCommandAction(project, commandText) {
       @Override
-      public void run() {
-        try {
-          LoadTextUtil.changeLineSeparators(project, virtualFile, newSeparator, this);
-        }
-        catch (IOException e) {
-          LOG.warn(e);
-        }
+      protected void run(@NotNull Result result) throws Throwable {
+        LoadTextUtil.changeLineSeparators(project, virtualFile, newSeparator, this);
       }
-    }, commandText, null);
+    }.execute();
   }
 }