From b437f30fc7eb6a330969e5ccf9c4b621e578d810 Mon Sep 17 00:00:00 2001 From: Holger Rapp Date: Mon, 12 Jul 2010 14:52:12 +0200 Subject: [PATCH] Applied patch from Chris Chambers --- doc/UltiSnips.txt | 11 ++++++++--- plugin/UltiSnips.vim | 13 +++++++++++++ test.py | 18 ++++++++++++++++++ 3 files changed, 39 insertions(+), 3 deletions(-) diff --git a/doc/UltiSnips.txt b/doc/UltiSnips.txt index 9d6e47c..3a5431b 100644 --- a/doc/UltiSnips.txt +++ b/doc/UltiSnips.txt @@ -552,13 +552,18 @@ individuals have contributed code to UltiSnips. In order of apperance. 8.1 Patches & Coding *UltiSnips-contricoding* -------------------- -JCEB - Jan Christoph Ebersbach -Michael Henry +Contributers are listed in chronological order: + + JCEB - Jan Christoph Ebersbach + Michael Henry + Chris Chambers 8.2 Snippets *UltiSnips-contrisnippets* ------------ -Alec Thomas (Python, smart def) +Contributers are listed in chronological order: + + Alec Thomas (Python, smart def) diff --git a/plugin/UltiSnips.vim b/plugin/UltiSnips.vim index f0aa0bb..34a73e7 100644 --- a/plugin/UltiSnips.vim +++ b/plugin/UltiSnips.vim @@ -40,12 +40,23 @@ endif " }}} "" FUNCTIONS {{{ +function! CompensateForPUM() + """ The CursorMovedI event is not triggered while the popup-menu is visible, + """ and it's by this event that UltiSnips updates its vim-state. The fix is + """ to explicitly check for the presence of the popup menu, and update + """ the vim-state accordingly. + if pumvisible() + py UltiSnips_Manager.cursor_moved() + endif +endfunction + function! UltiSnips_ExpandSnippet() py UltiSnips_Manager.expand() return "" endfunction function! UltiSnips_ExpandSnippetOrJump() + call CompensateForPUM() py UltiSnips_Manager.expand_or_jump() return "" endfunction @@ -56,11 +67,13 @@ function! UltiSnips_ListSnippets() endfunction function! UltiSnips_JumpBackwards() + call CompensateForPUM() py UltiSnips_Manager.jump_backwards() return "" endfunction function! UltiSnips_JumpForwards() + call CompensateForPUM() py UltiSnips_Manager.jump_forwards() return "" endfunction diff --git a/test.py b/test.py index 4e6ba5d..adb5ef4 100755 --- a/test.py +++ b/test.py @@ -1059,6 +1059,24 @@ class Completion_SimpleExample_ECR(_VimTest): wanted = "superkallifragilistik\nsuperkallifragilistik some more " \ "superkallifragilistik some more" +# We need >2 different words with identical starts to create the +# popup-menu: +COMPLETION_OPTIONS = "completion1\ncompletion2\n" + +class Completion_ForwardsJumpWithoutCOMPL_ACCEPT(_VimTest): + # completions should not be truncated when JF is activated without having + # pressed COMPL_ACCEPT (Bug #598903) + snippets = ("test", "$1 $2") + keys = COMPLETION_OPTIONS + "test" + EX + "com" + COMPL_KW + JF + "foo" + wanted = COMPLETION_OPTIONS + "completion1 foo" + +class Completion_BackwardsJumpWithoutCOMPL_ACCEPT(_VimTest): + # completions should not be truncated when JB is activated without having + # pressed COMPL_ACCEPT (Bug #598903) + snippets = ("test", "$1 $2") + keys = COMPLETION_OPTIONS + "test" + EX + "foo" + JF + "com" + COMPL_KW + \ + JB + "foo" + wanted = COMPLETION_OPTIONS + "foo completion1" ################### # SNIPPET OPTIONS #