From cd0e60bc0f7f7c13f7ecd9246db5fa47a22e30ec Mon Sep 17 00:00:00 2001 From: Holger Rapp Date: Sat, 18 Jul 2015 17:33:27 +0200 Subject: [PATCH] Remove no longer needed langmap translation. Vim now has the 'langnoremap' option that handles issues with mapping much more canonical. --- pythonx/UltiSnips/_vim.py | 64 +-------------------------------------- test/vim_test_case.py | 3 +- 2 files changed, 3 insertions(+), 64 deletions(-) diff --git a/pythonx/UltiSnips/_vim.py b/pythonx/UltiSnips/_vim.py index 39f5cc6..9665a2b 100644 --- a/pythonx/UltiSnips/_vim.py +++ b/pythonx/UltiSnips/_vim.py @@ -162,7 +162,7 @@ def select(start, end): move_cmd += '%iG%i|' % virtual_position(end.line + 1, end.col + 1) move_cmd += 'o%iG%i|o\\' % virtual_position( start.line + 1, start.col + 1) - feedkeys(_LangMapTranslator().translate(move_cmd)) + feedkeys(move_cmd) def _unmap_select_mode_mapping(): @@ -232,65 +232,3 @@ def _unmap_select_mode_mapping(): # This case should be rare enough to not bother us # though. pass - - -class _RealLangMapTranslator(object): - - """This cares for the Vim langmap option and basically reverses the - mappings. This was the only solution to get UltiSnips to work nicely with - langmap; other stuff I tried was using inoremap movement commands and - caching and restoring the langmap option. - - Note that this will not work if the langmap overwrites a character - completely, for example if 'j' is remapped, but nothing is mapped - back to 'j', then moving one line down is no longer possible and - UltiSnips will fail. - - """ - _maps = {} - _SEMICOLONS = re.compile(r"(? 1: - from_char, to_char = [a.replace('\\;', ';') for a in res] - from_chars += from_char - to_chars += to_char - else: - from_chars += char[::2] - to_chars += char[1::2] - self._maps[langmap] = (from_chars, to_chars) - - def translate(self, text): - """Inverse map 'text' through langmap.""" - langmap = eval('&langmap').strip() - if langmap == '': - return text - text = as_unicode(text) - if langmap not in self._maps: - self._create_translation(langmap) - for before, after in zip(*self._maps[langmap]): - text = text.replace(before, after) - return text - - -class _DummyLangMapTranslator(object): - - """If vim hasn't got the langmap compiled in, or is using langnoremap, we - never have to do anything. - - Then this class is used. - - """ - translate = lambda self, s: s - -_LangMapTranslator = _RealLangMapTranslator -if not int(eval('has("langmap")')): - _LangMapTranslator = _DummyLangMapTranslator -elif int(eval('exists("+langnoremap") && &langnoremap')): - _LangMapTranslator = _DummyLangMapTranslator diff --git a/test/vim_test_case.py b/test/vim_test_case.py index 2e1b6b5..ef3a7b9 100644 --- a/test/vim_test_case.py +++ b/test/vim_test_case.py @@ -9,7 +9,7 @@ import textwrap import time import unittest -from test.constant import PYTHON3, SEQUENCES +from test.constant import PYTHON3, SEQUENCES, EX from test.vim_interface import create_directory, TempFileManager @@ -129,6 +129,7 @@ class VimTestCase(unittest.TestCase, TempFileManager): vim_config.append('set buftype=nofile') vim_config.append('set shortmess=at') vim_config.append('let @" = ""') + assert EX == "\t" # Otherwise you need to change the next line vim_config.append('let g:UltiSnipsExpandTrigger=""') vim_config.append('let g:UltiSnipsJumpForwardTrigger="?"') vim_config.append('let g:UltiSnipsJumpBackwardTrigger="+"')