diff --git a/bec_widgets/widgets/plots/waveform/settings/curve_settings/curve_tree.py b/bec_widgets/widgets/plots/waveform/settings/curve_settings/curve_tree.py index a992354b..ab7bb703 100644 --- a/bec_widgets/widgets/plots/waveform/settings/curve_settings/curve_tree.py +++ b/bec_widgets/widgets/plots/waveform/settings/curve_settings/curve_tree.py @@ -127,13 +127,13 @@ class CurveRow(QTreeWidgetItem): # Populate 'live' and all available history scan indices self.scan_index_combo.addItem("live") history = getattr(self.curve_tree.client, "history", None) - num_scans = len(history) if history is not None else 0 + scan_number_list = history._scan_numbers # len(history) if history is not None else 0 # Restrict input to 'live' or valid scan numbers - validator = ScanIndexValidator(num_scans, self.scan_index_combo) + validator = ScanIndexValidator(len(scan_number_list), self.scan_index_combo) self.scan_index_combo.lineEdit().setValidator(validator) - for idx in range(num_scans): + for idx in scan_number_list: # Display scan numbers starting at 1 - self.scan_index_combo.addItem(str(idx + 1)) + self.scan_index_combo.addItem(str(idx)) # Select current scan number if set, otherwise default to 'live' if getattr(self.config, "scan_number", None) is not None: self.scan_index_combo.setCurrentText(str(self.config.scan_number)) diff --git a/tests/unit_tests/test_curve_settings.py b/tests/unit_tests/test_curve_settings.py index d7597d5f..13bb69c4 100644 --- a/tests/unit_tests/test_curve_settings.py +++ b/tests/unit_tests/test_curve_settings.py @@ -418,6 +418,7 @@ def test_export_data_history_curve(curve_tree_fixture, scan_history_factory): for m in msgs: wf.client.history._scan_data[m.scan_id] = m wf.client.history._scan_ids.append(m.scan_id) + wf.client.history._scan_numbers.append(m.scan_number) wf.client.queue.scan_storage.current_scan = None # Create a device row and select scan index "2"