From 31f318cb7e16312d876e16fdb6d0f910f077f3a5 Mon Sep 17 00:00:00 2001 From: John Szakmeister Date: Mon, 5 Aug 2013 14:49:03 -0400 Subject: [PATCH] Teach list_snippets_dict to escape apostrophes in the description. This was discovered while trying to use UltiSnips_SnippetsInCurrentScope() with some snippets that have apostrophes in the description (such as printf('...', ...)). --- plugin/UltiSnips/__init__.py | 2 +- test.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/plugin/UltiSnips/__init__.py b/plugin/UltiSnips/__init__.py index 55f9ff4..a171bfc 100644 --- a/plugin/UltiSnips/__init__.py +++ b/plugin/UltiSnips/__init__.py @@ -565,7 +565,7 @@ class SnippetManager(object): description = description[1:-1] _vim.command(as_unicode("let g:current_ulti_dict['{key}'] = '{val}'").format( - key=key.replace("'", "''"), val=description)) + key=key.replace("'", "''"), val=description.replace("'", "''"))) @err_to_scratch_buffer def list_snippets(self): diff --git a/test.py b/test.py index 5e3f021..af9be1d 100755 --- a/test.py +++ b/test.py @@ -3021,16 +3021,16 @@ class VerifyVimDict1(_VimTest): """check: correct type (4 means vim dictionary) correct length of dictionary (in this case we have on element if the use same prefix, dictionary should have 1 element) - correct description + correct description (including the apostrophe) if the prefix is mismatched no resulting dict should have 0 elements """ - snippets = ('testâ', 'abc123ά', '123êabc') + snippets = ('testâ', 'abc123ά', '123\'êabc') keys = ('test=(type(UltiSnips_SnippetsInCurrentScope()) . len(UltiSnips_SnippetsInCurrentScope()) . ' + 'UltiSnips_SnippetsInCurrentScope()["testâ"]' + ')\n' + '=len(UltiSnips_SnippetsInCurrentScope())\n') - wanted = 'test41123êabc0' + wanted = 'test41123\'êabc0' class VerifyVimDict2(_VimTest): """check: