To: vim_dev@googlegroups.com Subject: Patch 8.1.2330 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.1.2330 (after 8.1.2314) Problem: vi' does not always work when 'selection' is exclusive. Solution: Adjust start position. Files: src/search.c, src/testdir/test_textobjects.vim *** ../vim-8.1.2329/src/search.c 2019-11-17 17:32:24.373473658 +0100 --- src/search.c 2019-11-21 20:51:47.902005832 +0100 *************** *** 4412,4419 **** current_quote( oparg_T *oap, long count, ! int include, /* TRUE == include quote char */ ! int quotechar) /* Quote character */ { char_u *line = ml_get_curline(); int col_end; --- 4412,4419 ---- current_quote( oparg_T *oap, long count, ! int include, // TRUE == include quote char ! int quotechar) // Quote character { char_u *line = ml_get_curline(); int col_end; *************** *** 4421,4432 **** int inclusive = FALSE; int vis_empty = TRUE; // Visual selection <= 1 char int vis_bef_curs = FALSE; // Visual starts before cursor int inside_quotes = FALSE; // Looks like "i'" done before int selected_quote = FALSE; // Has quote inside selection int i; int restore_vis_bef = FALSE; // restore VIsual on abort ! /* Correct cursor when 'selection' is "exclusive". */ if (VIsual_active) { /* this only works within one line */ --- 4421,4435 ---- int inclusive = FALSE; int vis_empty = TRUE; // Visual selection <= 1 char int vis_bef_curs = FALSE; // Visual starts before cursor + int did_exclusive_adj = FALSE; // adjusted pos for 'selection' int inside_quotes = FALSE; // Looks like "i'" done before int selected_quote = FALSE; // Has quote inside selection int i; int restore_vis_bef = FALSE; // restore VIsual on abort ! // When 'selection' is "exclusive" move the cursor to where it would be ! // with 'selection' "inclusive", so that the logic is the same for both. ! // The cursor then is moved forward after adjusting the area. if (VIsual_active) { /* this only works within one line */ *************** *** 4437,4442 **** --- 4440,4456 ---- vis_empty = EQUAL_POS(VIsual, curwin->w_cursor); if (*p_sel == 'e') { + if (vis_bef_curs) + { + dec_cursor(); + did_exclusive_adj = TRUE; + } + else if (!vis_empty) + { + dec(&VIsual); + did_exclusive_adj = TRUE; + } + vis_empty = EQUAL_POS(VIsual, curwin->w_cursor); if (!vis_bef_curs && !vis_empty) { // VIsual needs to be the start of Visual selection. *************** *** 4447,4454 **** vis_bef_curs = TRUE; restore_vis_bef = TRUE; } - dec_cursor(); - vis_empty = EQUAL_POS(VIsual, curwin->w_cursor); } } --- 4461,4466 ---- *************** *** 4626,4632 **** { if (vis_empty || vis_bef_curs) { ! /* decrement cursor when 'selection' is not exclusive */ if (*p_sel != 'e') dec_cursor(); } --- 4638,4644 ---- { if (vis_empty || vis_bef_curs) { ! // decrement cursor when 'selection' is not exclusive if (*p_sel != 'e') dec_cursor(); } *************** *** 4663,4669 **** abort_search: if (VIsual_active && *p_sel == 'e') { ! inc_cursor(); if (restore_vis_bef) { pos_T t = curwin->w_cursor; --- 4675,4682 ---- abort_search: if (VIsual_active && *p_sel == 'e') { ! if (did_exclusive_adj) ! inc_cursor(); if (restore_vis_bef) { pos_T t = curwin->w_cursor; *** ../vim-8.1.2329/src/testdir/test_textobjects.vim 2019-11-17 17:32:24.373473658 +0100 --- src/testdir/test_textobjects.vim 2019-11-21 20:06:03.623718391 +0100 *************** *** 45,55 **** --- 45,62 ---- new call setline(1, "a 'bcde' f") set selection=exclusive + exe "norm! fdvhi'y" call assert_equal('bcde', @") + let @"='dummy' exe "norm! $gevi'y" call assert_equal('bcde', @") + + let @"='dummy' + exe "norm! 0fbhvi'y" + call assert_equal('bcde', @") + set selection&vim bw! endfunc *** ../vim-8.1.2329/src/version.c 2019-11-21 18:26:58.070235538 +0100 --- src/version.c 2019-11-21 20:07:24.307382153 +0100 *************** *** 739,740 **** --- 739,742 ---- { /* Add new patch number below this line */ + /**/ + 2330, /**/ -- Contrary to popular belief, Unix is user friendly. It just happens to be selective about who it makes friends with. -- Dave Parnas /// 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 ///