all calls to feedkeys are now routed through one function
This commit is contained in:
parent
6b38c5d186
commit
131e5fdc04
@ -24,6 +24,10 @@ def _vim_quote(s):
|
|||||||
"""Quote string s as Vim literal string."""
|
"""Quote string s as Vim literal string."""
|
||||||
return "'" + s.replace("'", "''") + "'"
|
return "'" + s.replace("'", "''") + "'"
|
||||||
|
|
||||||
|
def feedkeys(s, mode='n'):
|
||||||
|
"""Wrapper around vim's feedkeys that cares for langmap mappings"""
|
||||||
|
vim.command(r'call feedkeys("%s", "%s")' % (s, mode))
|
||||||
|
|
||||||
class _SnippetDictionary(object):
|
class _SnippetDictionary(object):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
self._snippets = []
|
self._snippets = []
|
||||||
@ -419,9 +423,9 @@ class VimState(object):
|
|||||||
|
|
||||||
if delta.line == delta.col == 0:
|
if delta.line == delta.col == 0:
|
||||||
if col == 0 or vim.eval("mode()") != 'i':
|
if col == 0 or vim.eval("mode()") != 'i':
|
||||||
vim.command(r'call feedkeys("\<Esc>i")')
|
feedkeys(r"\<Esc>i")
|
||||||
else:
|
else:
|
||||||
vim.command(r'call feedkeys("\<Esc>a")')
|
feedkeys(r"\<Esc>a")
|
||||||
else:
|
else:
|
||||||
if delta.line:
|
if delta.line:
|
||||||
move_lines = "%ij" % delta.line
|
move_lines = "%ij" % delta.line
|
||||||
@ -443,7 +447,7 @@ class VimState(object):
|
|||||||
do_select = "%ih" % (-delta.col+1)
|
do_select = "%ih" % (-delta.col+1)
|
||||||
|
|
||||||
|
|
||||||
vim.command(r'call feedkeys("\<Esc>%sv%s%s\<c-g>")' %
|
feedkeys(r"\<Esc>%sv%s%s\<c-g>" %
|
||||||
(move_one_right, move_lines, do_select))
|
(move_one_right, move_lines, do_select))
|
||||||
|
|
||||||
|
|
||||||
@ -556,10 +560,10 @@ class SnippetManager(object):
|
|||||||
|
|
||||||
if self._cs and (self._span_selected is not None):
|
if self._cs and (self._span_selected is not None):
|
||||||
# This only happens when a default value is delted using backspace
|
# This only happens when a default value is delted using backspace
|
||||||
vim.command(r'call feedkeys("i")')
|
feedkeys(r"i")
|
||||||
self._chars_entered('')
|
self._chars_entered('')
|
||||||
else:
|
else:
|
||||||
vim.command(r'call feedkeys("\<BS>")')
|
feedkeys(r"\<BS>")
|
||||||
|
|
||||||
def cursor_moved(self):
|
def cursor_moved(self):
|
||||||
self._vstate.update()
|
self._vstate.update()
|
||||||
@ -709,7 +713,7 @@ class SnippetManager(object):
|
|||||||
break
|
break
|
||||||
|
|
||||||
if feedkey:
|
if feedkey:
|
||||||
vim.command(r'call feedkeys("%s", "%s")' % (feedkey, mode))
|
feedkeys(feedkey, mode)
|
||||||
|
|
||||||
def _ensure_snippets_loaded(self):
|
def _ensure_snippets_loaded(self):
|
||||||
filetypes = vim.eval("&filetype").split(".") + [ "all" ]
|
filetypes = vim.eval("&filetype").split(".") + [ "all" ]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user