Skip to content

Commit 4c8aa17

Browse files
committed
rename event and handle it
1 parent 21a202c commit 4c8aa17

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

src/main/kotlin/com/smallcloud/refactai/panes/sharedchat/Events.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class EventNames {
3535
CHAT_PAGE_CHANGE("ide/chatPageChange"),
3636
IDE_TOOL_EDIT("ide/toolEdit"),
3737
FORCE_RELOAD_FILE_BY_PATH("ide/forceReloadFileByPath"),
38-
FORCE_RELOAD("ide/forceReload"),
38+
FORCE_RELOAD_PROJECT_TREE_FILES("ide/forceReloadProjectTreeFiles"),
3939
}
4040

4141
enum class ToChat(val value: String) {
@@ -146,8 +146,8 @@ class Events {
146146
return Editor.ForceReloadFileByPath(filePath)
147147
}
148148

149-
EventNames.FromChat.FORCE_RELOAD.value -> {
150-
return Editor.ForceReload()
149+
EventNames.FromChat.FORCE_RELOAD_PROJECT_TREE_FILES.value -> {
150+
return Editor.ForceReloadProjectTreeFiles()
151151
}
152152

153153
else -> null
@@ -387,7 +387,7 @@ class Events {
387387

388388
class SetSnippetToChat(payload: Snippet) : ToChat<Payload>(EventNames.ToChat.SET_SELECTED_SNIPPET, payload)
389389
class ForceReloadFileByPath(val path: String) : FromChat(EventNames.FromChat.FORCE_RELOAD_FILE_BY_PATH, path)
390-
class ForceReload(): FromChat(EventNames.FromChat.FORCE_RELOAD, null)
390+
class ForceReloadProjectTreeFiles(): FromChat(EventNames.FromChat.FORCE_RELOAD_PROJECT_TREE_FILES, null)
391391
}
392392

393393
object NewChat : ToChat<Unit>(EventNames.ToChat.NEW_CHAT, Unit)

src/main/kotlin/com/smallcloud/refactai/panes/sharedchat/SharedChatPane.kt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import com.intellij.openapi.Disposable
99
import com.intellij.openapi.actionSystem.DataContext
1010
import com.intellij.openapi.application.ApplicationManager
1111
import com.intellij.openapi.application.invokeLater
12-
import com.intellij.openapi.command.WriteCommandAction
1312
import com.intellij.openapi.diagnostic.Logger
1413
import com.intellij.openapi.editor.Caret
1514
import com.intellij.openapi.editor.EditorFactory
@@ -49,6 +48,7 @@ import javax.swing.JPanel
4948
import com.intellij.openapi.fileEditor.FileDocumentManager
5049
import com.intellij.openapi.fileEditor.FileEditorManagerEvent
5150
import com.intellij.openapi.fileEditor.FileEditorManagerListener
51+
import com.intellij.openapi.roots.ProjectRootManager
5252

5353
class SharedChatPane(val project: Project) : JPanel(), Disposable {
5454
private val logger = Logger.getInstance(SharedChatPane::class.java)
@@ -179,7 +179,7 @@ class SharedChatPane(val project: Project) : JPanel(), Disposable {
179179
logger.warn("handleForceReloadFileByPath: File not found: $fileName (sanitized: $sanitizedFileName)")
180180
return@invokeLater
181181
}
182-
VfsUtil.markDirtyAndRefresh(true, false, true, virtualFile)
182+
VfsUtil.markDirtyAndRefresh(true, true, true, virtualFile)
183183
logger.warn("handleForceReloadFileByPath: done for $fileName")
184184
}
185185
}
@@ -621,8 +621,10 @@ class SharedChatPane(val project: Project) : JPanel(), Disposable {
621621
this.handleForceReloadFileByPath(event.path)
622622
}
623623

624-
is Events.Editor.ForceReload -> {
625-
// TODO: handle force reload event.
624+
is Events.Editor.ForceReloadProjectTreeFiles -> {
625+
ProjectRootManager.getInstance(project).contentRoots.forEach {
626+
this.handleForceReloadFileByPath(it.path)
627+
}
626628
}
627629

628630
else -> Unit

0 commit comments

Comments
 (0)