def append(self, line, line_number=-1): """ Same as vim.current.window.buffer.append(), but with tracking changes. """ if line_number < 0: line_number = len(self) if not isinstance(line, list): line = [line] self[line_number:line_number] = [as_vimencoding(l) for l in line]
def __setitem__(self, key, value): """ Behaves as vim.current.window.buffer.__setitem__ except it tracks changes and applies them to the current snippet stack. """ 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])
def __setitem__(self, key, value): """ Behaves as vim.current.window.buffer.__setitem__ except it tracks changes and applies them to the current snippet stack. """ 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])
def __setslice__(self, i, j, text): # pylint:disable=no-self-use vim.current.buffer[i:j] = [as_vimencoding(l) for l in text]
def __setitem__(self, idx, text): if isinstance(idx, slice): # Py3 return self.__setslice__(idx.start, idx.stop, text) vim.current.buffer[idx] = as_vimencoding(text)
def __setslice__(self, i, j, text): vim.current.buffer[i:j] = [as_vimencoding(l) for l in text]
def eval(s): rv = vim.eval(as_vimencoding(s)) if not isinstance(rv, (dict, list)): return as_unicode(rv) return rv
def command(s): return as_unicode(vim.command(as_vimencoding(s)))
def command(cmd): """Wraps vim.command.""" return as_unicode(vim.command(as_vimencoding(cmd)))
def __setslice__(self, i, j, text): vim.current.buffer[i:j] = [ as_vimencoding(l) for l in text ]
def eval(text): """Wraps vim.eval.""" rv = vim.eval(as_vimencoding(text)) if not isinstance(rv, (dict, list)): return as_unicode(rv) return rv