More Umlaut fixes

This commit is contained in:
Holger Rapp 2012-01-11 15:47:11 +01:00
parent fc4e427774
commit 88f2c863aa
3 changed files with 15 additions and 7 deletions

View File

@ -53,7 +53,7 @@ if sys.version_info >= (3,0):
def as_unicode(s): def as_unicode(s):
if isinstance(s, bytes): if isinstance(s, bytes):
return s.decode("utf-8") return s.decode("utf-8")
return s return str(s)
def make_suitable_for_vim(s): def make_suitable_for_vim(s):
return s return s
@ -98,9 +98,9 @@ else:
return self.__cmp__(other) >= 0 return self.__cmp__(other) >= 0
def as_unicode(s): def as_unicode(s):
if not isinstance(s, unicode): if isinstance(s, str):
return s.decode("utf-8") return s.decode("utf-8")
return s return unicode(s)
def make_suitable_for_vim(s): def make_suitable_for_vim(s):
if isinstance(s, list): if isinstance(s, list):

View File

@ -9,7 +9,7 @@ import vim
from UltiSnips.Buffer import TextBuffer from UltiSnips.Buffer import TextBuffer
from UltiSnips.Compatibility import CheapTotalOrdering from UltiSnips.Compatibility import CheapTotalOrdering
from UltiSnips.Compatibility import compatible_exec from UltiSnips.Compatibility import compatible_exec, as_unicode
from UltiSnips.Geometry import Span, Position from UltiSnips.Geometry import Span, Position
from UltiSnips.Lexer import tokenize, EscapeCharToken, TransformationToken, \ from UltiSnips.Lexer import tokenize, EscapeCharToken, TransformationToken, \
TabStopToken, MirrorToken, PythonCodeToken, VimLCodeToken, ShellCodeToken TabStopToken, MirrorToken, PythonCodeToken, VimLCodeToken, ShellCodeToken
@ -209,7 +209,7 @@ class TextObject(CheapTotalOrdering):
############## ##############
def current_text(): def current_text():
def fget(self): def fget(self):
return str(self._current_text) return as_unicode(self._current_text)
def fset(self, text): def fset(self, text):
self._current_text = TextBuffer(text) self._current_text = TextBuffer(text)
@ -478,7 +478,7 @@ class VimLCode(TextObject):
TextObject.__init__(self, parent, token) TextObject.__init__(self, parent, token)
def _do_update(self): def _do_update(self):
self.current_text = str(vim.eval(self._code)) self.current_text = as_unicode(vim.eval(self._code))
def __repr__(self): def __repr__(self):
return "VimLCode(%s -> %s)" % (self._start, self._end) return "VimLCode(%s -> %s)" % (self._start, self._end)
@ -681,7 +681,7 @@ class PythonCode(TextObject):
if self._snip._rv_changed: if self._snip._rv_changed:
self.current_text = self._snip.rv self.current_text = self._snip.rv
else: else:
self.current_text = str(local_d["res"]) self.current_text = as_unicode(local_d["res"])
def __repr__(self): def __repr__(self):
return "PythonCode(%s -> %s)" % (self._start, self._end) return "PythonCode(%s -> %s)" % (self._start, self._end)

View File

@ -1944,6 +1944,14 @@ class Snippet_With_Umlauts_OverwriteNone(_VimTest):
snippets = ('ül', 'üü ${1:world} üü ${2:hello}ßß\nüüüü') snippets = ('ül', 'üü ${1:world} üü ${2:hello}ßß\nüüüü')
keys = 'te ül' + EX + JF + JF + "end" keys = 'te ül' + EX + JF + JF + "end"
wanted = "te üü world üü helloßß\nüüüüend" wanted = "te üü world üü helloßß\nüüüüend"
class Snippet_With_Umlauts_Mirrors(_VimTest):
snippets = ('ül', 'üü ${1:world} üü $1')
keys = 'te ül' + EX + "hello"
wanted = "te üü hello üü hello"
class Snippet_With_Umlauts_Python(_VimTest):
snippets = ('ül', 'üü ${1:world} üü `!p snip.rv = len(t[1])*"a"`')
keys = 'te ül' + EX + "hüüll"
wanted = "te üü hüüll üü aaaaa"
class Snippet_With_DoubleQuote_List(_VimTest): class Snippet_With_DoubleQuote_List(_VimTest):
snippets = _snip_quote('"') snippets = _snip_quote('"')