Merge pull request #864 from J3soon/fix_visual

Fix selecting one more character when using ${VISUAL}.
This commit is contained in:
Stanislav Seletskiy 2017-06-27 18:06:43 +07:00 committed by GitHub
commit 6b187827e2

View File

@ -8,6 +8,7 @@ from collections import deque, namedtuple
from UltiSnips import _vim
from UltiSnips.compatibility import as_unicode, byte2col
from UltiSnips.position import Position
import platform
_Placeholder = namedtuple('_FrozenPlaceholder', ['current_text', 'start', 'end'])
@ -117,7 +118,7 @@ class VisualContentPreserver(object):
self._placeholder = None
def conserve(self):
"""Save the last visual selection ond the mode it was made in."""
"""Save the last visual selection and the mode it was made in."""
sl, sbyte = map(int,
(_vim.eval("""line("'<")"""), _vim.eval("""col("'<")""")))
el, ebyte = map(int,
@ -128,13 +129,19 @@ class VisualContentPreserver(object):
_vim_line_with_eol = lambda ln: _vim.buf[ln] + '\n'
# Remove last character for windows
if platform.system() == 'Windows':
add = 0
else:
add = 1
if sl == el:
text = _vim_line_with_eol(sl - 1)[sc:ec + 1]
text = _vim_line_with_eol(sl - 1)[sc:ec + add]
else:
text = _vim_line_with_eol(sl - 1)[sc:]
for cl in range(sl, el - 1):
text += _vim_line_with_eol(cl)
text += _vim_line_with_eol(el - 1)[:ec + 1]
text += _vim_line_with_eol(el - 1)[:ec + add]
self._text = text
def conserve_placeholder(self, placeholder):