From 0cd0876cf06f1e3d82aa3b38860492d00a5a5d2b Mon Sep 17 00:00:00 2001 From: peter Date: Thu, 4 Oct 2012 15:43:45 +0200 Subject: [PATCH] give write access to template lookup element insert handler --- .../impl/TemplateExpressionLookupElement.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateExpressionLookupElement.java b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateExpressionLookupElement.java index c82c2af7e1a0..6d4ddb649dd2 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateExpressionLookupElement.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateExpressionLookupElement.java @@ -24,6 +24,8 @@ import com.intellij.codeInsight.lookup.LookupElement; import com.intellij.codeInsight.lookup.LookupElementDecorator; import com.intellij.codeInsight.lookup.LookupItem; import com.intellij.codeInsight.template.TemplateLookupSelectionHandler; +import com.intellij.openapi.application.Result; +import com.intellij.openapi.command.WriteCommandAction; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.EditorModificationUtil; import com.intellij.openapi.project.Project; @@ -59,13 +61,17 @@ class TemplateExpressionLookupElement extends LookupElementDecorator elements) { - InsertionContext context = createInsertionContext(this, myState.getPsiFile(), elements, myState.getEditor()); - handleInsert(context); + final InsertionContext context = createInsertionContext(this, myState.getPsiFile(), elements, myState.getEditor()); + new WriteCommandAction(context.getProject()) { + protected void run(Result result) throws Throwable { + handleInsert(context); + } + }.execute(); Disposer.dispose(context.getOffsetMap()); } @Override - public void handleInsert(InsertionContext context) { + public void handleInsert(final InsertionContext context) { LookupElement item = getDelegate(); Project project = context.getProject(); Editor editor = context.getEditor();