IDEA-89222 Navigate file shall accept files names/path starting with ./
authorpeter <peter@jetbrains.com>
Sun, 1 May 2016 15:14:57 +0000 (17:14 +0200)
committerpeter <peter@jetbrains.com>
Mon, 2 May 2016 06:58:55 +0000 (08:58 +0200)
java/java-tests/testSrc/com/intellij/navigation/ChooseByNameTest.groovy
platform/lang-impl/src/com/intellij/ide/actions/GotoFileItemProvider.java

index 40e002e5badb96e612a1a8e792cf21f14d7f7708..b311dc954b2068badf97a6cde1ee3a4ba5f66c31 100644 (file)
@@ -15,6 +15,7 @@
  */
 package com.intellij.navigation
 
+import com.intellij.ide.actions.GotoFileItemProvider
 import com.intellij.ide.util.gotoByName.*
 import com.intellij.lang.java.JavaLanguage
 import com.intellij.openapi.Disposable
@@ -166,6 +167,13 @@ class Intf {
 
   }
 
+  public void "test accept file paths starting with a dot"() {
+    def file = myFixture.addFileToProject("foo/index.html", "foo")
+    def model = new GotoFileModel(project)
+    def popup = ChooseByNamePopup.createPopup(project, model, new GotoFileItemProvider(project, null, model))
+    assert calcPopupElements(popup, "./foo/in") == [file]
+  }
+
   public void "test goto file can go to dir"() {
     PsiFile fooIndex = myFixture.addFileToProject("foo/index.html", "foo")
     PsiFile barIndex = myFixture.addFileToProject("bar.txt/bar.txt", "foo")
index d663258df68203517569eef286cc80026cf525b7..7fbb676c2f45d309a6368000e60c0f16110b2349 100644 (file)
@@ -67,6 +67,10 @@ public class GotoFileItemProvider extends DefaultChooseByNameItemProvider {
       }
     }
 
+    if (pattern.startsWith("./") || pattern.startsWith(".\\")) {
+      pattern = pattern.substring(1);
+    }
+
     return super.filterElements(base, pattern, everywhere, indicator, consumer);
   }
 }