From 4a0aa6f57306d693cf78a7098e826f87de1179cc Mon Sep 17 00:00:00 2001 From: liuk Date: Fri, 27 Sep 2024 11:32:23 +0800 Subject: [PATCH 1/2] fix(actions): The shire file downloaded from the marketplace has not been dynamically updated --- .../com/phodal/shirelang/actions/ShireFileChangesProvider.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/shirelang/src/main/kotlin/com/phodal/shirelang/actions/ShireFileChangesProvider.kt b/shirelang/src/main/kotlin/com/phodal/shirelang/actions/ShireFileChangesProvider.kt index 2dd656974..4c2c763bf 100644 --- a/shirelang/src/main/kotlin/com/phodal/shirelang/actions/ShireFileChangesProvider.kt +++ b/shirelang/src/main/kotlin/com/phodal/shirelang/actions/ShireFileChangesProvider.kt @@ -11,6 +11,7 @@ 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.VFileCopyEvent +import com.intellij.openapi.vfs.newvfs.events.VFileCreateEvent import com.intellij.openapi.vfs.newvfs.events.VFileDeleteEvent import com.intellij.openapi.vfs.newvfs.events.VFileEvent import com.intellij.openapi.vfs.newvfs.events.VFileMoveEvent @@ -81,7 +82,7 @@ internal class AsyncShireFileListener : AsyncFileListener, ShireFileListener { val afterChangedEvents = mutableListOf() for (event in events) { if (event is VFileDeleteEvent) beforeChangedEvents.add(event) - if (event is VFileCopyEvent || event is VFileMoveEvent) afterChangedEvents.add(event) + if (event is VFileCopyEvent || event is VFileMoveEvent || event is VFileCreateEvent) afterChangedEvents.add(event) } return object : AsyncFileListener.ChangeApplier { From 1ea4ef224d3fa2fe7c5b4249ac59837499ad34dc Mon Sep 17 00:00:00 2001 From: liuk Date: Fri, 27 Sep 2024 11:40:31 +0800 Subject: [PATCH 2/2] refactor(marketplace): Refresh the project directory after downloading the shire file from the marketplace --- .../shire/marketplace/ui/ShireMarketplaceTableView.kt | 4 ---- .../phodal/shire/marketplace/util/ShireDownloader.kt | 10 +++++++++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/main/kotlin/com/phodal/shire/marketplace/ui/ShireMarketplaceTableView.kt b/src/main/kotlin/com/phodal/shire/marketplace/ui/ShireMarketplaceTableView.kt index 63bafa251..832525560 100644 --- a/src/main/kotlin/com/phodal/shire/marketplace/ui/ShireMarketplaceTableView.kt +++ b/src/main/kotlin/com/phodal/shire/marketplace/ui/ShireMarketplaceTableView.kt @@ -52,10 +52,6 @@ class ShireMarketplaceTableView(val project: Project) { ShireDownloader(project, item).downloadAndUnzip() ShirelangNotifications.info(project, "Success Downloaded ${item.title}") - invokeLater { - project.guessProjectDir()?.refresh(true, true) - } - fireEditingStopped() } } diff --git a/src/main/kotlin/com/phodal/shire/marketplace/util/ShireDownloader.kt b/src/main/kotlin/com/phodal/shire/marketplace/util/ShireDownloader.kt index bb6101db7..c7fe78265 100644 --- a/src/main/kotlin/com/phodal/shire/marketplace/util/ShireDownloader.kt +++ b/src/main/kotlin/com/phodal/shire/marketplace/util/ShireDownloader.kt @@ -2,10 +2,12 @@ package com.phodal.shire.marketplace.util import com.intellij.openapi.application.ApplicationManager +import com.intellij.openapi.application.invokeLater import com.intellij.openapi.diagnostic.logger import com.intellij.openapi.progress.ProgressManager import com.intellij.openapi.progress.impl.BackgroundableProcessIndicator import com.intellij.openapi.project.Project +import com.intellij.openapi.project.guessProjectDir import com.intellij.openapi.util.Computable import com.intellij.openapi.util.io.FileUtil import com.intellij.util.download.DownloadableFileService @@ -49,7 +51,13 @@ class ShireDownloader(val project: Project, val item: ShirePackage) { downloadLock.writeLock().lock() try { val pluginDir: File = getPluginDir() - return downloadWithProgress { doDownload(pluginDir, downloader) } + return downloadWithProgress { + doDownload(pluginDir, downloader).apply { + invokeLater { + project.guessProjectDir()?.refresh(true, true) + } + } + } } finally { downloadLock.writeLock().unlock() }