From c3e0549076898f2bfe1c0901ea811e2716d1bfcc Mon Sep 17 00:00:00 2001 From: peter Date: Wed, 18 Apr 2012 19:57:14 +0200 Subject: [PATCH] IDEA-84834 Inconvenient live template completion with different keyword --- .../intellij/codeInsight/template/LiveTemplateTest.groovy | 8 +++++++- .../codeInsight/template/impl/ListTemplatesHandler.java | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/template/LiveTemplateTest.groovy b/java/java-tests/testSrc/com/intellij/codeInsight/template/LiveTemplateTest.groovy index abbc625a3a9b..31a483984333 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/template/LiveTemplateTest.groovy +++ b/java/java-tests/testSrc/com/intellij/codeInsight/template/LiveTemplateTest.groovy @@ -295,6 +295,13 @@ public class LiveTemplateTest extends LightCodeInsightFixtureTestCase { assert 'itar' in myFixture.lookupElementStrings } + public void testListTemplatesSearchesPrefixInDescription() { + myFixture.configureByText("a.java", "class A { main }") + + new ListTemplatesHandler().invoke(project, editor, myFixture.file); + assert myFixture.lookupElementStrings == ['psvm'] + } + public void testListTemplatesAction() { myFixture.configureByText("a.java", "class A {{ }}") @@ -308,7 +315,6 @@ public class LiveTemplateTest extends LightCodeInsightFixtureTestCase { myFixture.type('\b') new ListTemplatesHandler().invoke(project, editor, myFixture.file); assert myFixture.lookupElementStrings.containsAll(['iter', 'itco']) - assert !('toar' in myFixture.lookupElementStrings) LookupManager.getInstance(project).hideActiveLookup() myFixture.type('xxxxx') diff --git a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/ListTemplatesHandler.java b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/ListTemplatesHandler.java index 5171bfca10a1..7641fce4d3c0 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/ListTemplatesHandler.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/ListTemplatesHandler.java @@ -53,7 +53,7 @@ public class ListTemplatesHandler implements CodeInsightActionHandler { List matchingTemplates = new ArrayList(); ArrayList applicableTemplates = SurroundWithTemplateHandler.getApplicableTemplates(editor, file, false); for (TemplateImpl template : applicableTemplates) { - if (template.getKey().startsWith(prefix)) { + if (template.getKey().startsWith(prefix) || template.getDescription() != null && template.getDescription().contains(prefix)) { matchingTemplates.add(template); } }