diff --git a/platform/platform-impl/src/com/intellij/openapi/vfs/impl/local/FileWatcher.java b/platform/platform-impl/src/com/intellij/openapi/vfs/impl/local/FileWatcher.java index 7516febe596b..c5b459261fa8 100644 --- a/platform/platform-impl/src/com/intellij/openapi/vfs/impl/local/FileWatcher.java +++ b/platform/platform-impl/src/com/intellij/openapi/vfs/impl/local/FileWatcher.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -556,7 +556,7 @@ public class FileWatcher { case CREATE: case DELETE: for (String p : paths) { - myDirtyPaths.dirtyPaths.add(p); + myDirtyPaths.dirtyPathsRecursive.add(p); String parentPath = new File(p).getParent(); if (parentPath != null) { myDirtyPaths.dirtyPaths.add(parentPath); diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/vfs/local/FileWatcherTest.java b/platform/platform-tests/testSrc/com/intellij/openapi/vfs/local/FileWatcherTest.java index 8baa5a78c50f..7f52a1df5ff6 100644 --- a/platform/platform-tests/testSrc/com/intellij/openapi/vfs/local/FileWatcherTest.java +++ b/platform/platform-tests/testSrc/com/intellij/openapi/vfs/local/FileWatcherTest.java @@ -714,6 +714,33 @@ public class FileWatcherTest extends PlatformLangTestCase { } } + public void testDisplacementByIsomorphicTree() throws Exception { + File top = createTestDir("top"); + File up = createTestDir(top, "up"); + File middle = createTestDir(up, "middle"); + File file = createTestFile(middle, "file.txt", "original content"); + File up_copy = new File(top, "up_copy"); + FileUtil.copyDir(up, up_copy); + FileUtil.writeToFile(file, "new content"); + + VirtualFile vFile = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(file); + assertNotNull(vFile); + assertEquals("new content", VfsUtilCore.loadText(vFile)); + + LocalFileSystem.WatchRequest request = watch(up); + try { + myAccept = true; + FileUtil.rename(up, new File(top, "up.bak")); + FileUtil.rename(up_copy, up); + assertEvent(VFileContentChangeEvent.class, file.getPath()); + assertTrue(vFile.isValid()); + assertEquals("original content", VfsUtilCore.loadText(vFile)); + } + finally { + unwatch(request); + } + } + @NotNull private LocalFileSystem.WatchRequest watch(File watchFile) {