mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-87489 Subscribe to currentEditor flow to fix interpreter widget after project cloning
StatusBar.currentEditor is a StateFlow initialized with null that resolves asynchronously via a serviceAsync chain. After cloning, the widget's initial update() runs before the flow resolves, so getSelectedFile() returns null and the widget stays hidden. Subscribe to the flow so the widget re-evaluates once the editor becomes available. (cherry picked from commit db0cd436a76fef47e5a1913c2c23b5231c15c60a) IJ-MR-192257 GitOrigin-RevId: 79140e2a60ea656eae21fe9da1f8fdecdb2eb377
This commit is contained in:
committed by
intellij-monorepo-bot
parent
f564bebd60
commit
7e72b43d1d
+11
@@ -15,6 +15,7 @@ import com.intellij.openapi.roots.ModuleRootListener
|
||||
import com.intellij.openapi.ui.popup.ListPopup
|
||||
import com.intellij.openapi.util.registry.Registry
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
import com.intellij.openapi.wm.StatusBar
|
||||
import com.intellij.openapi.wm.StatusBarWidget
|
||||
import com.intellij.openapi.wm.StatusBarWidgetFactory
|
||||
import com.intellij.openapi.wm.impl.status.EditorBasedStatusBarPopup
|
||||
@@ -28,6 +29,7 @@ import com.jetbrains.python.sdk.PySdkPopupFactory.Companion.shortenNameInPopup
|
||||
import com.jetbrains.python.sdk.legacy.PythonSdkUtil
|
||||
import com.jetbrains.python.sdk.noInterpreterMarker
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
private const val ID: String = "pythonInterpreterWidget"
|
||||
|
||||
@@ -69,6 +71,15 @@ private class PySdkStatusBar(project: Project, scope: CoroutineScope) : EditorBa
|
||||
scope = scope) {
|
||||
private var module: Module? = null
|
||||
|
||||
override fun install(statusBar: StatusBar) {
|
||||
super.install(statusBar)
|
||||
// statusBar.currentEditor resolves asynchronously via serviceAsync chain (with null as initial value);
|
||||
// subscribe to it so the widget re-evaluates once the editor becomes available
|
||||
scope.launch {
|
||||
statusBar.currentEditor.collect { update() }
|
||||
}
|
||||
}
|
||||
|
||||
override fun getWidgetState(file: VirtualFile?): WidgetState {
|
||||
module = findModule(file) ?: return WidgetState.HIDDEN
|
||||
|
||||
|
||||
Reference in New Issue
Block a user