From cfa650a06fa3050f6c1a6c74a799fe1b8519127f Mon Sep 17 00:00:00 2001
From: Cedric Ziel <cedric@cedric-ziel.com>
Date: Tue, 21 Aug 2018 11:05:59 +0200
Subject: [PATCH] Move fix for YamlServiceArgumentInspection out of awt event

Fixes: #1037
Fixes: #993
Fixes: #1184
---
 .../intentions/yaml/YamlServiceArgumentInspection.java   | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/main/java/fr/adrienbrault/idea/symfony2plugin/intentions/yaml/YamlServiceArgumentInspection.java b/src/main/java/fr/adrienbrault/idea/symfony2plugin/intentions/yaml/YamlServiceArgumentInspection.java
index 13b346871..e435d9735 100644
--- a/src/main/java/fr/adrienbrault/idea/symfony2plugin/intentions/yaml/YamlServiceArgumentInspection.java
+++ b/src/main/java/fr/adrienbrault/idea/symfony2plugin/intentions/yaml/YamlServiceArgumentInspection.java
@@ -1,6 +1,7 @@
 package fr.adrienbrault.idea.symfony2plugin.intentions.yaml;
 
 import com.intellij.codeInspection.*;
+import com.intellij.openapi.command.WriteCommandAction;
 import com.intellij.openapi.project.Project;
 import com.intellij.psi.PsiElement;
 import com.intellij.psi.PsiElementVisitor;
@@ -131,9 +132,13 @@ public String getFamilyName() {
         public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor problemDescriptor) {
             final PsiElement serviceKeyValue = problemDescriptor.getPsiElement().getParent();
 
-            if(serviceKeyValue instanceof YAMLKeyValue) {
-                ServiceActionUtil.fixServiceArgument((YAMLKeyValue) serviceKeyValue);
+            if(!(serviceKeyValue instanceof YAMLKeyValue)) {
+                return;
             }
+
+            WriteCommandAction.writeCommandAction(project).withName("Service Update").run(() -> {
+                ServiceActionUtil.fixServiceArgument((YAMLKeyValue) serviceKeyValue);
+            });
         }
     }
 }