'Called whenever the cursor moved.'

@err_to_scratch_buffer.wrap
def _cursor_moved(self):

    self._should_update_textobjects = False
    if ((not self._csnippets) and self._inner_state_up):
        self._teardown_inner_state()
    self._vstate.remember_position()
    if (_vim.eval('mode()') not in 'in'):
        return
    if self._ignore_movements:
        self._ignore_movements = False
        return
    if self._csnippets:
        cstart = self._csnippets[0].start.line
        cend = (self._csnippets[0].end.line + self._vstate.diff_in_buffer_length)
        ct = _vim.buf[cstart:(cend + 1)]
        lt = self._vstate.remembered_buffer
        pos = _vim.buf.cursor
        lt_span = [0, len(lt)]
        ct_span = [0, len(ct)]
        initial_line = cstart
        if (lt and ct):
            while ((lt[(lt_span[1] - 1)] == ct[(ct_span[1] - 1)]) and (self._vstate.ppos.line < ((initial_line + lt_span[1]) - 1)) and (pos.line < ((initial_line + ct_span[1]) - 1)) and (lt_span[0] < lt_span[1]) and (ct_span[0] < ct_span[1])):
                ct_span[1] -= 1
                lt_span[1] -= 1
            while ((lt_span[0] < lt_span[1]) and (ct_span[0] < ct_span[1]) and (lt[lt_span[0]] == ct[ct_span[0]]) and (self._vstate.ppos.line >= initial_line) and (pos.line >= initial_line)):
                ct_span[0] += 1
                lt_span[0] += 1
                initial_line += 1
        ct_span[0] = max(0, (ct_span[0] - 1))
        lt_span[0] = max(0, (lt_span[0] - 1))
        initial_line = max(cstart, (initial_line - 1))
        lt = lt[lt_span[0]:lt_span[1]]
        ct = ct[ct_span[0]:ct_span[1]]
        try:
            (rv, es) = guess_edit(initial_line, lt, ct, self._vstate)
            if (not rv):
                lt = '\n'.join(lt)
                ct = '\n'.join(ct)
                es = diff(lt, ct, initial_line)
            self._csnippets[0].replay_user_edits(es, self._ctab)
        except IndexError:
            pass
    self._check_if_still_inside_snippet()
    if self._csnippets:
        self._csnippets[0].update_textobjects()
        self._vstate.remember_buffer(self._csnippets[0])
