IDEA-84834 Inconvenient live template completion with different keyword

This commit is contained in:
peter
2012-04-18 20:23:33 +02:00
parent 4afdd61d8d
commit c3e0549076
2 changed files with 8 additions and 2 deletions
@@ -295,6 +295,13 @@ public class LiveTemplateTest extends LightCodeInsightFixtureTestCase {
assert 'itar' in myFixture.lookupElementStrings
}
public void testListTemplatesSearchesPrefixInDescription() {
myFixture.configureByText("a.java", "class A { main<caret> }")
new ListTemplatesHandler().invoke(project, editor, myFixture.file);
assert myFixture.lookupElementStrings == ['psvm']
}
public void testListTemplatesAction() {
myFixture.configureByText("a.java", "class A {{ <caret> }}")
@@ -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')
@@ -53,7 +53,7 @@ public class ListTemplatesHandler implements CodeInsightActionHandler {
List<TemplateImpl> matchingTemplates = new ArrayList<TemplateImpl>();
ArrayList<TemplateImpl> 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);
}
}