More Umlaut fixes
This commit is contained in:
parent
fc4e427774
commit
88f2c863aa
@ -53,7 +53,7 @@ if sys.version_info >= (3,0):
|
||||
def as_unicode(s):
|
||||
if isinstance(s, bytes):
|
||||
return s.decode("utf-8")
|
||||
return s
|
||||
return str(s)
|
||||
|
||||
def make_suitable_for_vim(s):
|
||||
return s
|
||||
@ -98,9 +98,9 @@ else:
|
||||
return self.__cmp__(other) >= 0
|
||||
|
||||
def as_unicode(s):
|
||||
if not isinstance(s, unicode):
|
||||
if isinstance(s, str):
|
||||
return s.decode("utf-8")
|
||||
return s
|
||||
return unicode(s)
|
||||
|
||||
def make_suitable_for_vim(s):
|
||||
if isinstance(s, list):
|
||||
|
@ -9,7 +9,7 @@ import vim
|
||||
|
||||
from UltiSnips.Buffer import TextBuffer
|
||||
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.Lexer import tokenize, EscapeCharToken, TransformationToken, \
|
||||
TabStopToken, MirrorToken, PythonCodeToken, VimLCodeToken, ShellCodeToken
|
||||
@ -209,7 +209,7 @@ class TextObject(CheapTotalOrdering):
|
||||
##############
|
||||
def current_text():
|
||||
def fget(self):
|
||||
return str(self._current_text)
|
||||
return as_unicode(self._current_text)
|
||||
def fset(self, text):
|
||||
self._current_text = TextBuffer(text)
|
||||
|
||||
@ -478,7 +478,7 @@ class VimLCode(TextObject):
|
||||
TextObject.__init__(self, parent, token)
|
||||
|
||||
def _do_update(self):
|
||||
self.current_text = str(vim.eval(self._code))
|
||||
self.current_text = as_unicode(vim.eval(self._code))
|
||||
|
||||
def __repr__(self):
|
||||
return "VimLCode(%s -> %s)" % (self._start, self._end)
|
||||
@ -681,7 +681,7 @@ class PythonCode(TextObject):
|
||||
if self._snip._rv_changed:
|
||||
self.current_text = self._snip.rv
|
||||
else:
|
||||
self.current_text = str(local_d["res"])
|
||||
self.current_text = as_unicode(local_d["res"])
|
||||
|
||||
def __repr__(self):
|
||||
return "PythonCode(%s -> %s)" % (self._start, self._end)
|
||||
|
8
test.py
8
test.py
@ -1944,6 +1944,14 @@ class Snippet_With_Umlauts_OverwriteNone(_VimTest):
|
||||
snippets = ('ül', 'üü ${1:world} üü ${2:hello}ßß\nüüüü')
|
||||
keys = 'te ül' + EX + JF + JF + "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):
|
||||
snippets = _snip_quote('"')
|
||||
|
Loading…
Reference in New Issue
Block a user