To: vim_dev@googlegroups.com Subject: Patch 8.2.0590 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.0590 Problem: No 'backspace' value allows ignoring the insertion point. Solution: Add the "nostop" and 3 values. (Christian Brabandt, closes #5940) Files: runtime/doc/options.txt, src/edit.c, src/option.c, src/option.h, src/optionstr.c, src/testdir/gen_opt_test.vim, src/testdir/test_backspace_opt.vim *** ../vim-8.2.0589/runtime/doc/options.txt 2020-02-26 16:15:31.060386992 +0100 --- runtime/doc/options.txt 2020-04-17 19:33:06.093451961 +0200 *************** *** 914,919 **** --- 915,922 ---- eol allow backspacing over line breaks (join lines) start allow backspacing over the start of insert; CTRL-W and CTRL-U stop once at the start of insert. + nostop like start, except CTRL-W and CTRL-U do not stop at the start of + insert. When the value is empty, Vi compatible backspacing is used. *************** *** 922,927 **** --- 925,931 ---- 0 same as ":set backspace=" (Vi compatible) 1 same as ":set backspace=indent,eol" 2 same as ":set backspace=indent,eol,start" + 3 same as ":set backspace=indent,eol,nostop" See |:fixdel| if your or key does not do what you want. NOTE: This option is set to "" when 'compatible' is set. *** ../vim-8.2.0589/src/edit.c 2020-03-11 13:01:36.025436785 +0100 --- src/edit.c 2020-04-17 19:40:37.276185313 +0200 *************** *** 4884,4891 **** revins_on || #endif (curwin->w_cursor.col > mincol ! && (curwin->w_cursor.lnum != Insstart_orig.lnum ! || curwin->w_cursor.col != Insstart_orig.col))); } did_backspace = TRUE; } --- 4884,4893 ---- revins_on || #endif (curwin->w_cursor.col > mincol ! && (can_bs(BS_NOSTOP) ! || (curwin->w_cursor.lnum != Insstart_orig.lnum ! || curwin->w_cursor.col != Insstart_orig.col) ! ))); } did_backspace = TRUE; } *** ../vim-8.2.0589/src/option.c 2020-04-12 19:37:13.518297259 +0200 --- src/option.c 2020-04-17 19:33:06.097451947 +0200 *************** *** 1685,1690 **** --- 1685,1694 ---- *(char_u **)varp = vim_strsave( (char_u *)"indent,eol,start"); break; + case 3: + *(char_u **)varp = vim_strsave( + (char_u *)"indent,eol,nostop"); + break; } vim_free(oldval); if (origval == oldval) *************** *** 6818,6824 **** */ int can_bs( ! int what) // BS_INDENT, BS_EOL or BS_START { #ifdef FEAT_JOB_CHANNEL if (what == BS_START && bt_prompt(curbuf)) --- 6822,6828 ---- */ int can_bs( ! int what) // BS_INDENT, BS_EOL, BS_START or BS_NOSTOP { #ifdef FEAT_JOB_CHANNEL if (what == BS_START && bt_prompt(curbuf)) *************** *** 6826,6832 **** #endif switch (*p_bs) { ! case '2': return TRUE; case '1': return (what != BS_START); case '0': return FALSE; } --- 6830,6837 ---- #endif switch (*p_bs) { ! case '3': return TRUE; ! case '2': return (what != BS_NOSTOP); case '1': return (what != BS_START); case '0': return FALSE; } *** ../vim-8.2.0589/src/option.h 2020-03-30 19:30:07.129542925 +0200 --- src/option.h 2020-04-17 19:33:06.097451947 +0200 *************** *** 344,352 **** #define WIM_BUFLASTUSED 0x08 // arguments for can_bs() #define BS_INDENT 'i' // "Indent" ! #define BS_EOL 'o' // "eOl" #define BS_START 's' // "Start" // flags for the 'culopt' option #define CULOPT_LINE 0x01 // Highlight complete line --- 344,357 ---- #define WIM_BUFLASTUSED 0x08 // arguments for can_bs() + // each defined char should be unique over all values + // except for BS_START, that intentionally also matches BS_NOSTOP + // because BS_NOSTOP behaves exactly the same except it + // does not stop at the start of the insert point #define BS_INDENT 'i' // "Indent" ! #define BS_EOL 'l' // "eoL" #define BS_START 's' // "Start" + #define BS_NOSTOP 'p' // "nostoP // flags for the 'culopt' option #define CULOPT_LINE 0x01 // Highlight complete line *** ../vim-8.2.0589/src/optionstr.c 2020-03-16 20:27:34.987453212 +0100 --- src/optionstr.c 2020-04-17 19:33:06.097451947 +0200 *************** *** 68,74 **** static char *(p_ead_values[]) = {"both", "ver", "hor", NULL}; static char *(p_buftype_values[]) = {"nofile", "nowrite", "quickfix", "help", "terminal", "acwrite", "prompt", "popup", NULL}; static char *(p_bufhidden_values[]) = {"hide", "unload", "delete", "wipe", NULL}; ! static char *(p_bs_values[]) = {"indent", "eol", "start", NULL}; #ifdef FEAT_FOLDING static char *(p_fdm_values[]) = {"manual", "expr", "marker", "indent", "syntax", # ifdef FEAT_DIFF --- 68,74 ---- static char *(p_ead_values[]) = {"both", "ver", "hor", NULL}; static char *(p_buftype_values[]) = {"nofile", "nowrite", "quickfix", "help", "terminal", "acwrite", "prompt", "popup", NULL}; static char *(p_bufhidden_values[]) = {"hide", "unload", "delete", "wipe", NULL}; ! static char *(p_bs_values[]) = {"indent", "eol", "start", "nostop", NULL}; #ifdef FEAT_FOLDING static char *(p_fdm_values[]) = {"manual", "expr", "marker", "indent", "syntax", # ifdef FEAT_DIFF *************** *** 1910,1916 **** { if (VIM_ISDIGIT(*p_bs)) { ! if (*p_bs > '2' || p_bs[1] != NUL) errmsg = e_invarg; } else if (check_opt_strings(p_bs, p_bs_values, TRUE) != OK) --- 1910,1916 ---- { if (VIM_ISDIGIT(*p_bs)) { ! if (*p_bs > '3' || p_bs[1] != NUL) errmsg = e_invarg; } else if (check_opt_strings(p_bs, p_bs_values, TRUE) != OK) *** ../vim-8.2.0589/src/testdir/gen_opt_test.vim 2020-03-22 14:08:27.317399676 +0100 --- src/testdir/gen_opt_test.vim 2020-04-17 19:33:06.097451947 +0200 *************** *** 63,69 **** \ \ 'ambiwidth': [['', 'single'], ['xxx']], \ 'background': [['', 'light', 'dark'], ['xxx']], ! \ 'backspace': [[0, 2, '', 'eol', 'eol,start'], ['xxx']], \ 'backupcopy': [['yes', 'auto'], ['', 'xxx', 'yes,no']], \ 'backupext': [['xxx'], ['']], \ 'belloff': [['', 'all', 'copy,error'], ['xxx']], --- 63,69 ---- \ \ 'ambiwidth': [['', 'single'], ['xxx']], \ 'background': [['', 'light', 'dark'], ['xxx']], ! \ 'backspace': [[0, 2, 3, '', 'eol', 'eol,start', 'indent,eol,nostop'], ['4', 'xxx']], \ 'backupcopy': [['yes', 'auto'], ['', 'xxx', 'yes,no']], \ 'backupext': [['xxx'], ['']], \ 'belloff': [['', 'all', 'copy,error'], ['xxx']], *** ../vim-8.2.0589/src/testdir/test_backspace_opt.vim 2020-04-11 17:09:28.320426592 +0200 --- src/testdir/test_backspace_opt.vim 2020-04-17 19:33:06.097451947 +0200 *************** *** 19,24 **** --- 19,26 ---- call assert_equal('eol', &backspace) set backspace=start call assert_equal('start', &backspace) + set backspace=nostop + call assert_equal('nostop', &backspace) " Add the value set backspace= set backspace=indent *************** *** 27,33 **** --- 29,39 ---- call assert_equal('indent,eol', &backspace) set backspace+=start call assert_equal('indent,eol,start', &backspace) + set backspace+=nostop + call assert_equal('indent,eol,start,nostop', &backspace) " Delete the value + set backspace-=nostop + call assert_equal('indent,eol,start', &backspace) set backspace-=indent call assert_equal('eol,start', &backspace) set backspace-=start *************** *** 47,53 **** call assert_equal('1', &backspace) set backspace=2 call assert_equal('2', &backspace) ! call assert_false(match(Exec('set backspace=3'), '.*E474')) call assert_false(match(Exec('set backspace=10'), '.*E474')) " Cleared when 'compatible' is set --- 53,61 ---- call assert_equal('1', &backspace) set backspace=2 call assert_equal('2', &backspace) ! set backspace=3 ! call assert_equal('3', &backspace) ! call assert_false(match(Exec('set backspace=4'), '.*E474')) call assert_false(match(Exec('set backspace=10'), '.*E474')) " Cleared when 'compatible' is set *************** *** 101,106 **** --- 109,147 ---- \ "8 this shouldn't be deleted (not touched yet) vim7", \ ""], getline(1, '$')) + " Reset values + set compatible&vim + set visualbell&vim + set backspace&vim + + " Test new nostop option + %d_ + let expected = "foo bar foobar" + call setline(1, expected) + call cursor(1, 8) + exe ":norm! ianotherone\" + call assert_equal(expected, getline(1)) + call cursor(1, 8) + exe ":norm! ianothertwo\" + call assert_equal(expected, getline(1)) + + let content = getline(1) + for value in ['indent,nostop', 'eol,nostop', 'indent,eol,nostop', 'indent,eol,start,nostop'] + exe ":set bs=".. value + %d _ + call setline(1, content) + let expected = " foobar" + call cursor(1, 8) + exe ":norm! ianotherone\" + call assert_equal(expected, getline(1), 'CTRL-U backspace value: '.. &bs) + let expected = "foo foobar" + call setline(1, content) + call cursor(1, 8) + exe ":norm! ianothertwo\" + call assert_equal(expected, getline(1), 'CTRL-W backspace value: '.. &bs) + endfor + + " Reset options set compatible&vim set visualbell&vim set backspace&vim *** ../vim-8.2.0589/src/version.c 2020-04-17 19:23:01.483286414 +0200 --- src/version.c 2020-04-17 19:35:03.277118102 +0200 *************** *** 748,749 **** --- 748,751 ---- { /* Add new patch number below this line */ + /**/ + 590, /**/ -- If you had to identify, in one word, the reason why the human race has not achieved, and never will achieve, its full potential, that word would be "meetings." /// 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 ///