From 4b1723b32d2a2342f23a5163ef5310e0c7237e6a Mon Sep 17 00:00:00 2001 From: Googler Date: Fri, 8 Dec 2023 14:18:20 -0800 Subject: [PATCH] Improve query sync file listener PiperOrigin-RevId: 589240330 --- .../qsync/QuerySyncAsyncFileListener.java | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/base/src/com/google/idea/blaze/base/qsync/QuerySyncAsyncFileListener.java b/base/src/com/google/idea/blaze/base/qsync/QuerySyncAsyncFileListener.java index 2c5ec566988..88b9924c8ce 100644 --- a/base/src/com/google/idea/blaze/base/qsync/QuerySyncAsyncFileListener.java +++ b/base/src/com/google/idea/blaze/base/qsync/QuerySyncAsyncFileListener.java @@ -30,10 +30,10 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.vfs.AsyncFileListener; import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.openapi.vfs.newvfs.events.VFileContentChangeEvent; import com.intellij.openapi.vfs.newvfs.events.VFileCreateEvent; import com.intellij.openapi.vfs.newvfs.events.VFileEvent; import com.intellij.openapi.vfs.newvfs.events.VFileMoveEvent; +import com.intellij.openapi.vfs.newvfs.events.VFilePropertyChangeEvent; import java.nio.file.Path; import java.util.List; import java.util.concurrent.atomic.AtomicBoolean; @@ -83,6 +83,13 @@ private ImmutableList filterForProject( } private boolean requiresSync(VFileEvent event) { + if (event instanceof VFileCreateEvent || event instanceof VFileMoveEvent) { + return true; + } else if (event instanceof VFilePropertyChangeEvent + && ((VFilePropertyChangeEvent) event).getPropertyName().equals("name")) { + return true; + } + VirtualFile vf = event.getFile(); if (vf == null) { return false; @@ -92,17 +99,6 @@ private boolean requiresSync(VFileEvent event) { return true; } - if (event instanceof VFileCreateEvent || event instanceof VFileMoveEvent) { - return true; - } - - if (event instanceof VFileContentChangeEvent) { - // TODO: Check if file is not already part of graph - if (((VFileContentChangeEvent) event).getOldLength() == 0) { - return true; - } - } - return false; }