Added the possibility to backspace over newlines in tabstops

This commit is contained in:
Holger Rapp 2009-07-10 18:34:46 +02:00
parent 49aa031a95
commit ba6e0662b5
2 changed files with 24 additions and 8 deletions

View File

@ -11,6 +11,8 @@ from UltiSnips.Geometry import Position
from UltiSnips.TextObjects import *
from UltiSnips.Buffer import VimBuffer
from UltiSnips.debug import debug
class Snippet(object):
_INDENT = re.compile(r"^[ \t]*")
@ -277,6 +279,9 @@ class SnippetManager(object):
elif self._vstate.moved.line == 0 and self._vstate.moved.col<0:
# Some deleting was going on
self._backspace(-self._vstate.moved.col)
elif self._vstate.moved.line < 0:
# Backspace over line end
self._backspace(1)
else:
line = vim.current.line

27
test.py
View File

@ -22,15 +22,15 @@ EX = "\t" # EXPAND
def send(s,session):
os.system("screen -x %s -X stuff '%s'" % (session,s))
time.sleep(.005)
def type(str, session):
def type(str, session, sleeptime):
"""
Send the keystrokes to vim via screen. Pause after each char, so
vim can handle this
"""
for c in str:
send(c, session)
time.sleep(sleeptime)
class _VimTest(unittest.TestCase):
snippets = ("dummy", "donotdefine")
@ -38,12 +38,13 @@ class _VimTest(unittest.TestCase):
text_after = " --- some text after --- "
wanted = ""
keys = ""
sleeptime = 0.01
def send(self,s):
send(s, self.session)
def type(self,s):
type(s, self.session)
type(s, self.session, self.sleeptime)
def check_output(self):
wanted = self.text_before + '\n\n' + self.wanted + \
@ -102,6 +103,8 @@ EOF
time.sleep(.05)
tries -= 1
# TODO: correct indent after newline in snippet
#
##################
# Simple Expands #
##################
@ -115,6 +118,18 @@ class SimpleExpandTwice_ExceptCorrectResult(_SimpleExpands):
keys = "hallo" + EX + '\nhallo' + EX
wanted = "Hallo Welt!\nHallo Welt!"
class SimpleExpandNewLineAndBackspae_ExceptCorrectResult(_SimpleExpands):
keys = "hallo" + EX + "\nHallo Welt!\n\n\b\b\b\b\b"
wanted = "Hallo Welt!\nHallo We"
def setUp(self):
self.send(":set backspace=eol,start\n")
_SimpleExpands.setUp(self)
def tearDown(self):
self.send(":set backspace=\n")
_SimpleExpands.tearDown(self)
class SimpleExpandTypeAfterExpand_ExceptCorrectResult(_SimpleExpands):
keys = "hallo" + EX + "and again"
wanted = "Hallo Welt!and again"
@ -170,8 +185,6 @@ class TabStopNoReplace_ExceptCorrectResult(_VimTest):
keys = "echo" + EX
wanted = "echo Hallo"
# TODO: multiline tabstops, maybe?
class TabStopEscapingWhenSelected_ECR(_VimTest):
snippets = ("test", "snip ${1:default}")
keys = "test" + EX + ESC + "0ihi"
@ -345,6 +358,7 @@ class TabStop_Shell_InDefValue_Overwrite(_VimTest):
wanted = "Hallo overwrite endand more"
class TabStop_Shell_ShebangPython(_VimTest):
sleeptime = 0.05 # Do this very slowly
snippets = ("test", """Hallo ${1:now `#!/usr/bin/env python
print "Hallo Welt"
`} end""")
@ -421,7 +435,6 @@ class MultilineTabStopSimpleMirrorMultiline1_ExceptCorrectResult(_VimTest):
snippets = ("test", "$1\n$1\n$1")
keys = "test" + EX + "hallo Du\nHi"
wanted = "hallo Du\nHi\nhallo Du\nHi\nhallo Du\nHi"
# TODO: Multiline delete over line endings
class MultilineTabStopSimpleMirrorDeleteInLine_ExceptCorrectResult(_VimTest):
snippets = ("test", "$1\n$1\n$1")
keys = "test" + EX + "hallo Du\nHi\b\bAch Blah"
@ -629,8 +642,6 @@ class Transformation_OptionReplaceGlobalMatchInReplace_ECR(_VimTest):
keys = "test" + EX + "a, nice, building"
wanted = "a, nice, building a, nice, building"
# TODO: conditional in conditional, case folding recursive
###################
# CURSOR MOVEMENT #
###################