VimBuffer.cursor.line is no 0 based
This commit is contained in:
parent
30286f5446
commit
a4f8e12c24
@ -676,9 +676,8 @@ class SnippetManager(object):
|
||||
|
||||
def _check_if_still_inside_snippet(self):
|
||||
# Did we leave the snippet with this movement?
|
||||
line, col = _vim.buf.cursor
|
||||
if self._cs and (
|
||||
not self._cs.start <= Position(line - 1, col) <= self._cs.end
|
||||
not self._cs.start <= _vim.buf.cursor <= self._cs.end
|
||||
):
|
||||
self._current_snippet_is_done()
|
||||
self._reinit()
|
||||
@ -789,9 +788,7 @@ class SnippetManager(object):
|
||||
""" Expands the given snippet, and handles everything
|
||||
that needs to be done with it.
|
||||
"""
|
||||
lineno, col = _vim.buf.cursor
|
||||
# Adjust before, maybe the trigger is not the complete word
|
||||
|
||||
text_before = before
|
||||
if snippet.matched:
|
||||
text_before = before[:-len(snippet.matched)]
|
||||
@ -799,8 +796,8 @@ class SnippetManager(object):
|
||||
self._unset_offending_vim_options(snippet)
|
||||
|
||||
if self._cs:
|
||||
start = Position(lineno-1, len(text_before))
|
||||
end = Position(lineno-1, len(before))
|
||||
start = Position(_vim.buf.cursor.line, len(text_before))
|
||||
end = Position(_vim.buf.cursor.line, len(before))
|
||||
|
||||
si = snippet.launch(text_before, self._visual_content,
|
||||
self._cs.find_parent_for_new_to(start), start, end)
|
||||
@ -808,8 +805,8 @@ class SnippetManager(object):
|
||||
|
||||
self._csnippets.append(si)
|
||||
else:
|
||||
start = Position(lineno-1, len(text_before))
|
||||
end = Position(lineno-1, len(before))
|
||||
start = Position(_vim.buf.cursor.line, len(text_before))
|
||||
end = Position(_vim.buf.cursor.line, len(before))
|
||||
self._csnippets.append(snippet.launch(text_before, self._visual_content, None, start, end))
|
||||
self._visual_content.reset()
|
||||
|
||||
|
@ -42,14 +42,17 @@ class VimBuffer(object):
|
||||
return before, after
|
||||
|
||||
def cursor():
|
||||
"""The current windows cursor"""
|
||||
"""
|
||||
The current windows cursor. Note that this is 0 based in col and 0
|
||||
based in line which is different from Vim's cursor.
|
||||
"""
|
||||
def fget(self):
|
||||
return vim_cursor()
|
||||
def fset(self, value):
|
||||
set_vim_cursor(*value)
|
||||
line, col = vim_cursor()
|
||||
return Position(line - 1, col)
|
||||
def fset(self, pos):
|
||||
set_vim_cursor(pos.line + 1, pos.col)
|
||||
return locals()
|
||||
cursor = property(**cursor())
|
||||
|
||||
buf = VimBuffer()
|
||||
|
||||
|
||||
@ -195,7 +198,7 @@ def text_to_vim(start, end, text):
|
||||
|
||||
# Open any folds this might have created
|
||||
debug("start: %r" % (start))
|
||||
buf.cursor = start.line + 1, start.col
|
||||
buf.cursor = start
|
||||
vim.command("normal zv")
|
||||
|
||||
new_end = _calc_end(lines, start)
|
||||
|
@ -116,12 +116,11 @@ class _VimCursor(NoneditableTextObject):
|
||||
"""Helper class to keep track of the Vim Cursor"""
|
||||
|
||||
def __init__(self, parent):
|
||||
line, col = _vim.buf.cursor
|
||||
NoneditableTextObject.__init__(
|
||||
self, parent, Position(line-1, col), Position(line-1, col)
|
||||
self, parent, _vim.buf.cursor, _vim.buf.cursor
|
||||
)
|
||||
|
||||
def to_vim(self):
|
||||
assert(self._start == self._end)
|
||||
_vim.buf.cursor = self._start.line + 1, self._start.col
|
||||
_vim.buf.cursor = self._start
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user