Moved tab_selected also into SnippetManager
This commit is contained in:
parent
86a400df80
commit
5935131a2a
@ -85,7 +85,7 @@ class TextObject(object):
|
||||
|
||||
moved_lines = new_end.line - oldend.line
|
||||
moved_cols = new_end.col - oldend.col
|
||||
|
||||
|
||||
self._current_text.replace_text(c.start, oldend, c._current_text)
|
||||
|
||||
self._move_textobjects_behind(c.start, oldend, moved_lines,
|
||||
@ -389,7 +389,6 @@ class SnippetInstance(ChangeableText):
|
||||
self._end = self._current_text.calc_end(start)
|
||||
|
||||
self._cts = None
|
||||
self._tab_selected = False
|
||||
|
||||
TextObject.update(self)
|
||||
|
||||
@ -405,14 +404,10 @@ class SnippetInstance(ChangeableText):
|
||||
self.add_tabstop(0,ts)
|
||||
|
||||
TextObject.update(self)
|
||||
|
||||
|
||||
def __repr__(self):
|
||||
return "SnippetInstance(%s -> %s)" % (self._start, self._end)
|
||||
|
||||
def tab_selected(self):
|
||||
return self._tab_selected
|
||||
tab_selected = property(tab_selected)
|
||||
|
||||
def select_next_tab(self, backwards = False):
|
||||
if self._cts == 0:
|
||||
return None
|
||||
@ -438,14 +433,5 @@ class SnippetInstance(ChangeableText):
|
||||
if 0 not in self._tabstops:
|
||||
return None
|
||||
|
||||
self._tab_selected = True
|
||||
|
||||
return self._tabstops[self._cts]
|
||||
|
||||
# TODO: handling of input should be done completly outside this class
|
||||
def backspace(self,count):
|
||||
cts = self._tabstops[self._cts]
|
||||
cts.current_text = cts.current_text[:-count]
|
||||
|
||||
self.update()
|
||||
|
||||
|
@ -190,6 +190,7 @@ class SnippetManager(object):
|
||||
self._snippets = {}
|
||||
self._csnippet = None
|
||||
self._ctab = None
|
||||
self._tab_selected = False
|
||||
|
||||
def add_snippet(self, trigger, value, descr):
|
||||
if "all" not in self._snippets:
|
||||
@ -218,12 +219,12 @@ class SnippetManager(object):
|
||||
if self._csnippet:
|
||||
self._expect_move_wo_change = True
|
||||
self._ctab = self._csnippet.select_next_tab(backwards)
|
||||
if self._ctab is None:
|
||||
self._csnippet = None
|
||||
|
||||
return True
|
||||
else:
|
||||
if self._ctab:
|
||||
self._vstate.select_range(self._ctab.abs_range)
|
||||
self._tab_selected = True
|
||||
else:
|
||||
self._csnippet = None
|
||||
return True
|
||||
|
||||
self._vstate.update()
|
||||
return True
|
||||
@ -277,6 +278,7 @@ class SnippetManager(object):
|
||||
# TODO: this code is duplicated above
|
||||
self._ctab = self._csnippet.select_next_tab()
|
||||
if self._ctab is not None:
|
||||
self._tab_selected = True
|
||||
self._vstate.select_range(self._ctab.abs_range)
|
||||
|
||||
self._vstate.update()
|
||||
@ -320,9 +322,9 @@ class SnippetManager(object):
|
||||
self.reset()
|
||||
|
||||
def _chars_entered(self, chars):
|
||||
if self._csnippet._tab_selected:
|
||||
if self._tab_selected:
|
||||
self._ctab.current_text = chars
|
||||
self._csnippet._tab_selected = False
|
||||
self._tab_selected = False
|
||||
else:
|
||||
self._ctab.current_text += chars
|
||||
|
||||
@ -350,7 +352,7 @@ class SnippetManager(object):
|
||||
def backspace_while_selected(self):
|
||||
# BS was called in select mode
|
||||
|
||||
if self._csnippet and self._csnippet.tab_selected:
|
||||
if self._csnippet and self._tab_selected:
|
||||
# This only happens when a default value is delted using backspace
|
||||
old_range = self._csnippet.abs_range
|
||||
vim.command(r'call feedkeys("i")')
|
||||
|
Loading…
Reference in New Issue
Block a user