Skip to content

Commit 676255c

Browse files
committed
fix: Simplify URL handling and service initialization
- Replace BrowserUtil.browse(URL(url)) with BrowserUtil.browse(url) - Use getService(Class) instead of service<T>() extension function - Refactor ToolWindowStateListener to use standard conditional logic
1 parent 9e13ec6 commit 676255c

File tree

3 files changed

+6
-8
lines changed

3 files changed

+6
-8
lines changed

src/main/kotlin/ai/devchat/core/handlers/OpenLinkRequestHandler.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class OpenLinkRequestHandler(project: Project, requestAction: String, metadata:
1717

1818
override fun action() {
1919
val url = payload!!.getString("url")
20-
BrowserUtil.browse(URL(url))
20+
BrowserUtil.browse(url)
2121
send()
2222
}
2323
}

src/main/kotlin/ai/devchat/plugin/DevChatToolWindowFactory.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class DevChatToolWindowFactory : ToolWindowFactory, DumbAware, Disposable {
5959
Log.info("-----------> DevChatToolWindowFactory.createToolWindowContent started")
6060

6161
try {
62-
project.service<RecentFilesTracker>()
62+
project.getService(RecentFilesTracker::class.java)
6363
Log.info("-----------> RecentFilesTracker service initialized")
6464

6565
val devChatService = project.getService(DevChatService::class.java)

src/main/kotlin/ai/devchat/plugin/ToolWindowStateListener.kt

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import ai.devchat.common.Constants.ASSISTANT_NAME_ZH
44
import ai.devchat.common.DevChatBundle
55
import ai.devchat.storage.DevChatState
66
import ai.devchat.storage.ToolWindowState
7-
import ai.grazie.utils.applyIf
87
import com.intellij.openapi.application.runInEdt
98
import com.intellij.openapi.wm.ToolWindowManager
109
import com.intellij.openapi.wm.ex.ToolWindowManagerListener
@@ -15,13 +14,12 @@ class ToolWindowStateListener : ToolWindowManagerListener {
1514
super.toolWindowsRegistered(ids, toolWindowManager)
1615
ids.find { it == ASSISTANT_NAME_ZH }?.let {
1716
runInEdt {
18-
toolWindowManager.getToolWindow(it)?.applyIf(
19-
DevChatState.instance.lastToolWindowState == ToolWindowState.SHOWN.name
20-
) {
21-
while (!this.isAvailable) {
17+
val toolWindow = toolWindowManager.getToolWindow(it)
18+
if (DevChatState.instance.lastToolWindowState == ToolWindowState.SHOWN.name && toolWindow != null) {
19+
while (!toolWindow.isAvailable) {
2220
Thread.sleep(1000)
2321
}
24-
this.show()
22+
toolWindow.show()
2523
}
2624
}
2725
}

0 commit comments

Comments
 (0)