<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _history_buffer_pos_changed(self, _):
 """ 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)