mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
ListTemplate action: do not overwrite prefix-matched template with template
that was found by description
This commit is contained in:
+5
@@ -0,0 +1,5 @@
|
||||
class A {
|
||||
public static void main() {
|
||||
template.with.desc<caret>
|
||||
}
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
class A {
|
||||
public static void main() {
|
||||
template with description<caret>
|
||||
}
|
||||
}
|
||||
@@ -33,6 +33,7 @@ public class ListTemplateActionTest extends LightCodeInsightFixtureTestCase {
|
||||
TemplateManagerImpl.setTemplateTesting(getProject(), getTestRootDisposable());
|
||||
addTemplate("simple", "simple template text", "description");
|
||||
addTemplate("complex key", "complex template text", "");
|
||||
addTemplate("template.with.desc", "template with description", "desc");
|
||||
}
|
||||
|
||||
private void addTemplate(String key, String text, String description) {
|
||||
@@ -92,6 +93,10 @@ public class ListTemplateActionTest extends LightCodeInsightFixtureTestCase {
|
||||
public void testComplexKeyWithNotMatchedPrefixAfterNonJavaCharacter() {
|
||||
doTest("complex key");
|
||||
}
|
||||
|
||||
public void testTemplateShouldNotBeReplacedByOtherTemplateMatchedByDescription() {
|
||||
doTest("template.with.desc");
|
||||
}
|
||||
|
||||
private void doTest(@NotNull String lookupText) {
|
||||
myFixture.configureByFile(getTestName(false) + ".java");
|
||||
|
||||
+1
-1
@@ -120,7 +120,7 @@ public class ListTemplatesHandler implements CodeInsightActionHandler {
|
||||
}
|
||||
}
|
||||
|
||||
if (searchInDescription) {
|
||||
if (searchInDescription && !matchingTemplates.containsKey(template)) {
|
||||
String templateDescription = template.getDescription();
|
||||
if (!prefixWithoutDots.isEmpty() && templateDescription != null && prefixSearchPattern.matcher(templateDescription).matches()) {
|
||||
matchingTemplates.put(template, prefixWithoutDots);
|
||||
|
||||
Reference in New Issue
Block a user