diff --git a/platform/platform-impl/src/com/intellij/ide/SaveAndSyncHandlerImpl.java b/platform/platform-impl/src/com/intellij/ide/SaveAndSyncHandlerImpl.java index 80a6b1ac8d67..1cec7a4e16bf 100644 --- a/platform/platform-impl/src/com/intellij/ide/SaveAndSyncHandlerImpl.java +++ b/platform/platform-impl/src/com/intellij/ide/SaveAndSyncHandlerImpl.java @@ -32,6 +32,7 @@ import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.vfs.newvfs.ManagingFS; import com.intellij.openapi.vfs.newvfs.NewVirtualFile; import com.intellij.openapi.vfs.newvfs.RefreshQueue; +import com.intellij.openapi.vfs.newvfs.RefreshSession; import com.intellij.util.Alarm; import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; @@ -56,6 +57,8 @@ public class SaveAndSyncHandlerImpl implements ApplicationComponent, SaveAndSync private final AtomicInteger myBlockSyncOnFrameActivationCount = new AtomicInteger(); private final Alarm myRefreshDelayAlarm = new Alarm(Alarm.ThreadToUse.SWING_THREAD); + private long myRefreshSessionId = 0; + public static SaveAndSyncHandlerImpl getInstance(){ return (SaveAndSyncHandlerImpl) ApplicationManager.getApplication().getComponent(SaveAndSyncHandler.class); } @@ -168,7 +171,6 @@ public class SaveAndSyncHandlerImpl implements ApplicationComponent, SaveAndSync if (canSyncOrSave()) { refreshOpenFiles(); } - maybeRefresh(ModalityState.NON_MODAL); } }, 300, ModalityState.NON_MODAL); @@ -178,7 +180,15 @@ public class SaveAndSyncHandlerImpl implements ApplicationComponent, SaveAndSync public void maybeRefresh(@NotNull ModalityState modalityState) { if (myBlockSyncOnFrameActivationCount.get() == 0) { LOG.debug("VFS refresh started"); - RefreshQueue.getInstance().refresh(true, true, null, modalityState, ManagingFS.getInstance().getLocalRoots()); + + RefreshQueue queue = RefreshQueue.getInstance(); + queue.cancelSession(myRefreshSessionId); + + RefreshSession session = queue.createSession(true, true, null, modalityState); + session.addAllFiles(ManagingFS.getInstance().getLocalRoots()); + myRefreshSessionId = session.getId(); + session.launch(); + LOG.debug("VFS refresh finished"); } }