diff --git a/UltiSnips/python.snippets b/UltiSnips/python.snippets index 41a3645..efca35d 100644 --- a/UltiSnips/python.snippets +++ b/UltiSnips/python.snippets @@ -36,8 +36,8 @@ DOXYGEN = 0x2 SPHINX = 0x3 GOOGLE = 0x4 -SINGLE_QUOTES = 0x1 -DOUBLE_QUOTES = 0x2 +SINGLE_QUOTES = "'" +DOUBLE_QUOTES = '"' class Arg(object): @@ -69,9 +69,28 @@ def get_quoting_style(snip): return DOUBLE_QUOTES def triple_quotes(snip): - if get_quoting_style(snip) == SINGLE_QUOTES: - return "'''" - return '"""' + return get_quoting_style(snip) * 3 + +def triple_quotes_handle_trailing(snip, quoting_style): + if not hasattr(snip, '_tqt'): + _, col = vim.current.window.cursor + line = vim.current.line + + # Handle already existing quote chars, usually from an autoclose plugin + # like delimitMate. + _ret = quoting_style * 3 + while True: + try: + nextc = line[col] + except IndexError: + break + if nextc == quoting_style and len(_ret): + _ret = _ret[1:] + col = col+1 + else: + break + snip._tqt = _ret + snip.rv = snip._tqt def get_style(snip): style = snip.opt("g:ultisnips_python_style", "normal")