From fc4e42777408699b965dabc5db424644a29c8cd2 Mon Sep 17 00:00:00 2001 From: Holger Rapp Date: Wed, 11 Jan 2012 14:23:13 +0100 Subject: [PATCH] Bug 908139: Fix sunmap problems with unprintable chars in lhs. This is only a workaround really --- plugin/UltiSnips/__init__.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/plugin/UltiSnips/__init__.py b/plugin/UltiSnips/__init__.py index bd49046..4b4f021 100644 --- a/plugin/UltiSnips/__init__.py +++ b/plugin/UltiSnips/__init__.py @@ -1,5 +1,7 @@ #!/usr/bin/env python # encoding: utf-8 +# +from debug import debug # TODO from functools import wraps import glob @@ -596,7 +598,7 @@ class VimState(object): "| redir END") # Check if any mappings where found - all_maps = list(filter(len, vim.eval(r"_tmp_smaps").splitlines())) + all_maps = list(filter(len, as_unicode(vim.eval(r"_tmp_smaps")).splitlines())) if (len(all_maps) == 1 and all_maps[0][0] not in " sv"): # "No maps found". String could be localized. Hopefully # it doesn't start with any of these letters in any @@ -627,7 +629,19 @@ class VimState(object): continue # Actually unmap it - vim.command("sunmap %s %s" % (option,trig)) + try: + cmd = as_unicode("silent! sunmap %s %s") % (option, trig) + vim.command(cmd.encode("utf-8")) + except: + # Bug 908139: ignore unmaps that fail because of + # unprintable characters. This is not ideal because we + # will not be able to unmap lhs with any unprintable + # character. If the lhs stats with a printable + # character this will leak to the user when he tries to + # type this character as a first in a selected tabstop. + # This case should be rare enough to not bother us + # though. + pass class SnippetManager(object): def __init__(self):