MCPcopy Create free account
hub / github.com/davidhalter/jedi-vim / PythonToVimStr

Class PythonToVimStr

pythonx/jedi_vim.py:40–61  ·  view source on GitHub ↗

Vim has a different string implementation of single quotes

Source from the content-addressed store, hash-verified

38
39
40class PythonToVimStr(unicode):
41 """ Vim has a different string implementation of single quotes """
42 __slots__ = []
43
44 def __new__(cls, obj, encoding='UTF-8'):
45 if not (is_py3 or isinstance(obj, unicode)):
46 obj = unicode.__new__(cls, obj, encoding)
47
48 # Vim cannot deal with zero bytes:
49 obj = obj.replace('\0', '\\0')
50 return unicode.__new__(cls, obj)
51
52 def __repr__(self):
53 # this is totally stupid and makes no sense but vim/python unicode
54 # support is pretty bad. don't ask how I came up with this... It just
55 # works...
56 # It seems to be related to that bug: http://bugs.python.org/issue5876
57 if unicode is str:
58 s = self
59 else:
60 s = self.encode('UTF-8')
61 return '"%s"' % s.replace('\\', '\\\\').replace('"', r'\"')
62
63
64class VimError(Exception):

Callers 8

echoFunction · 0.90
_catch_exceptionFunction · 0.85
completionsFunction · 0.85
_goto_specific_nameFunction · 0.85
show_goto_multi_resultsFunction · 0.85
show_documentationFunction · 0.85
show_call_signaturesFunction · 0.85
rename_visualFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected