From bbe6815a5c699d5e521abfc9adbc96477f984f09 Mon Sep 17 00:00:00 2001 From: peter Date: Mon, 25 Aug 2014 18:39:05 +0200 Subject: [PATCH] IDEA-128733 FindInPath: "Recursively" option with Directory Scope selected doesn't work --- .../com/intellij/find/FindManagerTest.java | 22 +++++++++++++++++++ .../intellij/find/impl/FindInProjectTask.java | 2 +- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/java/java-tests/testSrc/com/intellij/find/FindManagerTest.java b/java/java-tests/testSrc/com/intellij/find/FindManagerTest.java index e40e2c160822..cf876693e2f7 100644 --- a/java/java-tests/testSrc/com/intellij/find/FindManagerTest.java +++ b/java/java-tests/testSrc/com/intellij/find/FindManagerTest.java @@ -343,6 +343,28 @@ public class FindManagerTest extends DaemonAnalyzerTestCase { assertSize(2, findUsages(findModel)); } + public void testNonRecursiveDirectory() throws Exception { + VirtualFile root = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(createTempDirectory()); + addSourceContentToRoots(myModule, root); + + VirtualFile foo = createChildDirectory(root, "foo"); + VirtualFile bar = createChildDirectory(foo, "bar"); + createFile(myModule, root, "A.txt", "goo doo"); + createFile(myModule, foo, "A.txt", "goo doo"); + createFile(myModule, bar, "A.txt", "doo goo"); + + FindModel findModel = FindManagerTestUtils.configureFindModel("done"); + findModel.setProjectScope(false); + findModel.setDirectoryName(foo.getPath()); + findModel.setStringToFind("doo"); + + findModel.setWithSubdirectories(true); + assertSize(2, findUsages(findModel)); + + findModel.setWithSubdirectories(false); + assertSize(1, findUsages(findModel)); + } + public void testReplaceRegexp() { FindModel findModel = new FindModel(); findModel.setStringToFind("bug_(?=here)"); diff --git a/platform/lang-impl/src/com/intellij/find/impl/FindInProjectTask.java b/platform/lang-impl/src/com/intellij/find/impl/FindInProjectTask.java index 7e9e71d7a94d..7dfdbbce16d7 100644 --- a/platform/lang-impl/src/com/intellij/find/impl/FindInProjectTask.java +++ b/platform/lang-impl/src/com/intellij/find/impl/FindInProjectTask.java @@ -421,7 +421,7 @@ class FindInProjectTask { SearchScope customScope = myFindModel.getCustomScope(); GlobalSearchScope scope = myPsiDirectory != null - ? GlobalSearchScopesCore.directoryScope(myPsiDirectory, true) + ? GlobalSearchScopesCore.directoryScope(myPsiDirectory, myFindModel.isWithSubdirectories()) : myModule != null ? myModule.getModuleContentScope() : customScope instanceof GlobalSearchScope