diff --git a/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/PostfixLiveTemplate.java b/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/PostfixLiveTemplate.java index d7a3b26e7f8b..586f8769ca21 100644 --- a/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/PostfixLiveTemplate.java +++ b/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/PostfixLiveTemplate.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -127,7 +127,8 @@ public class PostfixLiveTemplate extends CustomLiveTemplateBase { newContext = addSemicolonIfNeeded(editor, editor.getDocument(), newContext, currentOffset - key.length()); expandTemplate(template, editor, newContext); } - else { + // don't care about errors in multiCaret mode + else if (editor.getCaretModel().getAllCarets().size() == 1) { LOG.error("Template not found by key: " + key); } } diff --git a/java/java-tests/testData/codeInsight/template/postfix/completion/multiCaret.java b/java/java-tests/testData/codeInsight/template/postfix/completion/multiCaret.java new file mode 100644 index 000000000000..e1fb30ae174a --- /dev/null +++ b/java/java-tests/testData/codeInsight/template/postfix/completion/multiCaret.java @@ -0,0 +1,12 @@ +class A { + Object foo; + Object bar; + + public static void main(String[] args) { + foo == null + + bar + + bar == null + } +} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/template/postfix/completion/multiCaret_after.java b/java/java-tests/testData/codeInsight/template/postfix/completion/multiCaret_after.java new file mode 100644 index 000000000000..3cc22e3f8eec --- /dev/null +++ b/java/java-tests/testData/codeInsight/template/postfix/completion/multiCaret_after.java @@ -0,0 +1,16 @@ +class A { + Object foo; + Object bar; + + public static void main(String[] args) { + if (foo == null) { + + } + + bar.if + + if (bar == null) { + + } + } +} \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/template/postfix/completion/TemplatesCompletionTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/template/postfix/completion/TemplatesCompletionTest.java index 39fd2fbd4f8c..585283316f87 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/template/postfix/completion/TemplatesCompletionTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/template/postfix/completion/TemplatesCompletionTest.java @@ -156,6 +156,10 @@ public class TemplatesCompletionTest extends CompletionAutoPopupTestCase { checkResultByFile(); } + public void testMultiCaret() { + doCompleteTest(".if", '\t'); + } + @Override protected String getBasePath() { return JavaTestUtil.getRelativeJavaTestDataPath() + "/codeInsight/template/postfix/completion";