'Behaves as vim.current.window.buffer.__setitem__ except it tracks
changes and applies them to the current snippet stack.'

def __setitem__(self, key, value):

    if isinstance(key, slice):
        value = [as_vimencoding(line) for line in value]
        changes = list(self._get_diff(key.start, key.stop, value))
        self._buffer[key.start:key.stop] = [line.strip('\n') for line in value]
    else:
        value = as_vimencoding(value)
        changes = list(self._get_line_diff(key, self._buffer[key], value))
        self._buffer[key] = value
    self._change_tick += 1
    if self._forward_edits:
        for change in changes:
            self._apply_change(change)
        if self._snippets_stack:
            self._vstate.remember_buffer(self._snippets_stack[0])
