Skip to content

Commit

Permalink
fix: avoid reloading browser
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoMeijer authored and reymondzzzz committed Sep 5, 2024
1 parent e7434a0 commit ddcf584
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import com.smallcloud.refactai.account.AccountManagerChangedNotifier
import com.smallcloud.refactai.io.InferenceGlobalContext
import com.smallcloud.refactai.io.InferenceGlobalContextChangedNotifier
import com.smallcloud.refactai.lsp.LSPProcessHolder.Companion.BIN_PATH
import com.smallcloud.refactai.lsp.LSPProcessHolderChangedNotifier
import com.smallcloud.refactai.panes.sharedchat.Events.ActiveFile.ActiveFileToChat
import com.smallcloud.refactai.panes.sharedchat.Events.Editor
import com.smallcloud.refactai.panes.sharedchat.browser.ChatWebView
Expand Down Expand Up @@ -214,6 +215,14 @@ class SharedChatPane(val project: Project) : JPanel(), Disposable {
}
})

editor.project.messageBus
.connect(PluginState.instance)
.subscribe(LSPProcessHolderChangedNotifier.TOPIC, object : LSPProcessHolderChangedNotifier {
override fun lspIsActive(isActive: Boolean) {
this@SharedChatPane.sendUserConfig()
}
})

ApplicationManager.getApplication().invokeLater {
CoroutineScope(Dispatchers.Main).launch {
FimCache.subscribe { data ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,18 +136,6 @@ class ChatWebView(val editor: Editor, val messageHandler: (event: Events.FromCha

}, browser.cefBrowser)

editor.project.messageBus.connect(PluginState.instance)
.subscribe(LSPProcessHolderChangedNotifier.TOPIC, object : LSPProcessHolderChangedNotifier {
override fun lspIsActive(isActive: Boolean) {
if (isActive) {
setupReact = false
installedScript = false
browser.cefBrowser.reload()
addMessageHandler(myJSQueryOpenInBrowser)
}
}
})

browser.createImmediately()
browser
}
Expand Down

0 comments on commit ddcf584

Please sign in to comment.