To: vim_dev@googlegroups.com Subject: Patch 8.0.0283 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.0.0283 Problem: The return value of mode() does not indicate that completion is active in Replace and Insert mode. (Zhen-Huan (Kenny) Hu) Solution: Add "c" or "x" for two kinds of completion. (Yegappan Lakshmanan, closes #1397) Test some more modes. Files: runtime/doc/eval.txt, src/evalfunc.c, src/testdir/test_functions.vim, src/testdir/test_mapping.vim *** ../vim-8.0.0282/runtime/doc/eval.txt 2017-01-28 18:23:49.725039260 +0100 --- runtime/doc/eval.txt 2017-02-01 16:16:52.343450573 +0100 *************** *** 5839,5847 **** S Select by line CTRL-S Select blockwise i Insert R Replace |R| Rv Virtual Replace |gR| ! c Command-line cv Vim Ex mode |gQ| ce Normal Ex mode |Q| r Hit-enter prompt --- 5848,5860 ---- S Select by line CTRL-S Select blockwise i Insert + ic Insert mode completion |compl-generic| + ix Insert mode |i_CTRL-X| completion R Replace |R| + Rc Replace mode completion |compl-generic| Rv Virtual Replace |gR| ! Rx Replace mode |i_CTRL-X| completion ! c Command-line editing cv Vim Ex mode |gQ| ce Normal Ex mode |Q| r Hit-enter prompt *** ../vim-8.0.0282/src/evalfunc.c 2017-01-29 20:31:17.872621591 +0100 --- src/evalfunc.c 2017-02-01 16:42:06.749685417 +0100 *************** *** 7783,7803 **** } else #endif ! if (State & REPLACE_FLAG) ! buf[0] = 'R'; ! else ! buf[0] = 'i'; } ! else if (State & CMDLINE) { buf[0] = 'c'; ! if (exmode_active) buf[1] = 'v'; ! } ! else if (exmode_active) ! { ! buf[0] = 'c'; ! buf[1] = 'e'; } else { --- 7783,7808 ---- } else #endif ! { ! if (State & REPLACE_FLAG) ! buf[0] = 'R'; ! else ! buf[0] = 'i'; ! #ifdef FEAT_INS_EXPAND ! if (ins_compl_active()) ! buf[1] = 'c'; ! else if (ctrl_x_mode == 1) ! buf[1] = 'x'; ! #endif ! } } ! else if ((State & CMDLINE) || exmode_active) { buf[0] = 'c'; ! if (exmode_active == EXMODE_VIM) buf[1] = 'v'; ! else if (exmode_active == EXMODE_NORMAL) ! buf[1] = 'e'; } else { *** ../vim-8.0.0282/src/testdir/test_functions.vim 2017-01-29 15:45:07.161783704 +0100 --- src/testdir/test_functions.vim 2017-02-01 17:15:06.872947192 +0100 *************** *** 304,307 **** --- 304,392 ---- call assert_equal("Ⱥ Ⱦ", toupper("ⱥ ⱦ")) endfunc + " Tests for the mode() function + let current_modes = '' + func! Save_mode() + let g:current_modes = mode(0) . '-' . mode(1) + return '' + endfunc + + func! Test_mode() + new + call append(0, ["Blue Ball Black", "Brown Band Bowl", ""]) + + inoremap =Save_mode() + + normal! 3G + exe "normal i\\" + call assert_equal('i-i', g:current_modes) + exe "normal i\uBa\\\u" + call assert_equal('i-ic', g:current_modes) + exe "normal iBro\\\u" + call assert_equal('i-ic', g:current_modes) + exe "normal iBa\\\u" + call assert_equal('i-ix', g:current_modes) + exe "normal iBa\\\\u" + call assert_equal('i-ic', g:current_modes) + exe "normal iBro\\\\u" + call assert_equal('i-ic', g:current_modes) + exe "normal iBro\\\\\u" + call assert_equal('i-ic', g:current_modes) + exe "normal iCom\\\u" + call assert_equal('i-ic', g:current_modes) + exe "normal iCom\\\\u" + call assert_equal('i-ic', g:current_modes) + + exe "normal RBa\\\u" + call assert_equal('R-Rc', g:current_modes) + exe "normal RBro\\\u" + call assert_equal('R-Rc', g:current_modes) + exe "normal RBa\\\u" + call assert_equal('R-Rx', g:current_modes) + exe "normal RBa\\\\u" + call assert_equal('R-Rc', g:current_modes) + exe "normal RBro\\\\u" + call assert_equal('R-Rc', g:current_modes) + exe "normal RBro\\\\\u" + call assert_equal('R-Rc', g:current_modes) + exe "normal RCom\\\u" + call assert_equal('R-Rc', g:current_modes) + exe "normal RCom\\\\u" + call assert_equal('R-Rc', g:current_modes) + + call assert_equal('n', mode(0)) + call assert_equal('n', mode(1)) + " How to test operator-pending mode? + + call feedkeys("v", 'xt') + call assert_equal('v', mode()) + call assert_equal('v', mode(1)) + call feedkeys("\V", 'xt') + call assert_equal('V', mode()) + call assert_equal('V', mode(1)) + call feedkeys("\\", 'xt') + call assert_equal("\", mode()) + call assert_equal("\", mode(1)) + call feedkeys("\", 'xt') + + call feedkeys("gh", 'xt') + call assert_equal('s', mode()) + call assert_equal('s', mode(1)) + call feedkeys("\gH", 'xt') + call assert_equal('S', mode()) + call assert_equal('S', mode(1)) + call feedkeys("\g\", 'xt') + call assert_equal("\", mode()) + call assert_equal("\", mode(1)) + call feedkeys("\", 'xt') + + call feedkeys(":echo \=Save_mode()\\", 'xt') + call assert_equal('c-c', g:current_modes) + call feedkeys("gQecho \=Save_mode()\\vi\", 'xt') + call assert_equal('c-cv', g:current_modes) + " How to test Ex mode? + + bwipe! + iunmap + endfunc *** ../vim-8.0.0282/src/testdir/test_mapping.vim 2016-09-08 21:39:00.000000000 +0200 --- src/testdir/test_mapping.vim 2017-02-01 17:20:05.863024601 +0100 *************** *** 110,115 **** --- 110,117 ---- call feedkeys(":call append(line('$'), '+')\", "xt") call assert_equal('+', getline('$')) + iunmap a + iunmap c set nomodified endfunc *************** *** 120,126 **** $-1 call feedkeys("0qqdw.ifoo\qj0@q\", "xt") call assert_equal(['fooc d', 'fooc d'], getline(line('$') - 1, line('$'))) ! unmap . set nomodified endfunc --- 122,128 ---- $-1 call feedkeys("0qqdw.ifoo\qj0@q\", "xt") call assert_equal(['fooc d', 'fooc d'], getline(line('$') - 1, line('$'))) ! nunmap . set nomodified endfunc *** ../vim-8.0.0282/src/version.c 2017-02-01 15:03:25.679840157 +0100 --- src/version.c 2017-02-01 17:07:10.796008356 +0100 *************** *** 766,767 **** --- 766,769 ---- { /* Add new patch number below this line */ + /**/ + 283, /**/ -- I wonder, do vegetarians eat fruit bats? /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///