def _history_buffer_pos_changed(self, _: Buffer) -> None:
        """When the cursor changes in the history buffer. Synchronize."""
        # Only when this buffer has the focus.
        if self.app.current_buffer == self.history_buffer:
            line_no = self.history_buffer.document.cursor_position_row

            if line_no in self.history_mapping.selected_lines:
                default_lineno = (
                    sorted(self.history_mapping.selected_lines).index(line_no)
                    + self.history_mapping.result_line_offset
                )

                self.default_buffer.cursor_position = (
                    self.default_buffer.document.translate_row_col_to_index(
                        default_lineno, 0
                    )
                )
When the cursor changes in the history buffer. Synchronize.
src/ptpython/history_browser.py