Skip to content

Commit efa7b98

Browse files
authored
Merge pull request JetBrains#126 from lensvol/fix-settings-detection
Fix device detection in settings panel.
2 parents ff0615e + fe94882 commit efa7b98

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/main/kotlin/com/jetbrains/micropython/settings/MicroPythonFacet.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,20 +134,20 @@ class MicroPythonFacet(facetType: FacetType<out Facet<*>, *>, module: Module, na
134134

135135
fun getOrDetectDevicePathSynchronously(): String? =
136136
if (autoDetectDevicePath)
137-
detectDevicePathSynchronously()
137+
detectDevicePathSynchronously(configuration.deviceProvider)
138138
else
139139
devicePath
140140

141-
fun detectDevicePathSynchronously(): String? {
141+
fun detectDevicePathSynchronously(deviceProvider: MicroPythonDeviceProvider): String? {
142142
ApplicationManager.getApplication().assertIsDispatchThread()
143143

144144
var detectedDevicePath: String? = null
145-
val deviceProviderName = configuration.deviceProvider.presentableName
145+
val deviceProviderName = deviceProvider.presentableName
146146
val progress = ProgressManager.getInstance()
147147

148148
progress.runProcessWithProgressSynchronously({
149149
progress.progressIndicator.text = "Detecting connected $deviceProviderName devices..."
150-
val detected = findSerialPorts(configuration.deviceProvider, progress.progressIndicator).firstOrNull()
150+
val detected = findSerialPorts(deviceProvider, progress.progressIndicator).firstOrNull()
151151
ApplicationManager.getApplication().invokeLater {
152152
if (detected == null) {
153153
Messages.showErrorDialog(module.project,

src/main/kotlin/com/jetbrains/micropython/settings/MicroPythonSettingsPanel.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class MicroPythonSettingsPanel(private val module: Module) : JPanel() {
5252
add(devicePath, BorderLayout.CENTER)
5353
add(JButton("Detect").apply {
5454
addActionListener {
55-
devicePath.text = module.microPythonFacet?.detectDevicePathSynchronously() ?: ""
55+
devicePath.text = module.microPythonFacet?.detectDevicePathSynchronously(selectedProvider) ?: ""
5656
}
5757
}, BorderLayout.EAST)
5858
})

0 commit comments

Comments
 (0)