From 22e1a27ca93ee132842c5b4c3a51eeddd3656bd4 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Tue, 6 Dec 2016 18:22:25 +0100 Subject: [PATCH] [vfs] fixes missed notifications on flat file watch root changes on macOS (IDEA-165018) --- .../vfs/impl/local/CanonicalPathMap.java | 2 -- .../openapi/vfs/local/FileWatcherTest.kt | 24 +++++++++---------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/vfs/impl/local/CanonicalPathMap.java b/platform/platform-impl/src/com/intellij/openapi/vfs/impl/local/CanonicalPathMap.java index 83bf0ff6efd5..d25e8e85ac13 100644 --- a/platform/platform-impl/src/com/intellij/openapi/vfs/impl/local/CanonicalPathMap.java +++ b/platform/platform-impl/src/com/intellij/openapi/vfs/impl/local/CanonicalPathMap.java @@ -144,7 +144,6 @@ class CanonicalPathMap { String rootParent = new File(root).getParent(); if (rootParent != null && FileUtil.namesEqual(path, rootParent)) { changedPaths.add(root); - continue ext; } } } @@ -158,7 +157,6 @@ class CanonicalPathMap { String rootParent = new File(root).getParent(); if (rootParent != null && FileUtil.namesEqual(path, rootParent)) { changedPaths.add(root); - continue ext; } } } diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/vfs/local/FileWatcherTest.kt b/platform/platform-tests/testSrc/com/intellij/openapi/vfs/local/FileWatcherTest.kt index f7935304edb1..d866e48192a3 100644 --- a/platform/platform-tests/testSrc/com/intellij/openapi/vfs/local/FileWatcherTest.kt +++ b/platform/platform-tests/testSrc/com/intellij/openapi/vfs/local/FileWatcherTest.kt @@ -119,23 +119,23 @@ class FileWatcherTest : BareTestFixtureTestCase() { } @Test fun testFileRoot() { - val file = tempDir.newFile("test.txt") - refresh(file) + val files = arrayOf(tempDir.newFile("test1.txt"), tempDir.newFile("test2.txt")) + files.forEach { refresh(it) } + files.forEach { watch(it, false) } - watch(file, false) - assertEvents({ file.writeText("new content") }, mapOf(file to 'U')) - assertEvents({ file.delete() }, mapOf(file to 'D')) - assertEvents({ file.writeText("re-creation") }, mapOf(file to 'C')) + assertEvents({ files.forEach { it.writeText("new content") } }, files.map { it to 'U' }.toMap()) + assertEvents({ files.forEach { it.delete() } }, files.map { it to 'D' }.toMap()) + assertEvents({ files.forEach { it.writeText("re-creation") } }, files.map { it to 'C' }.toMap()) } @Test fun testFileRootRecursive() { - val file = tempDir.newFile("test.txt") - refresh(file) + val files = arrayOf(tempDir.newFile("test1.txt"), tempDir.newFile("test2.txt")) + files.forEach { refresh(it) } + files.forEach { watch(it, true) } - watch(file, true) - assertEvents({ file.writeText("new content") }, mapOf(file to 'U')) - assertEvents({ file.delete() }, mapOf(file to 'D')) - assertEvents({ file.writeText("re-creation") }, mapOf(file to 'C')) + assertEvents({ files.forEach { it.writeText("new content") } }, files.map { it to 'U' }.toMap()) + assertEvents({ files.forEach { it.delete() } }, files.map { it to 'D' }.toMap()) + assertEvents({ files.forEach { it.writeText("re-creation") } }, files.map { it to 'C' }.toMap()) } @Test fun testNonCanonicallyNamedFileRoot() {