• R/O
  • SSH

vim: Commit

Mirror of the Vim source from https://github.com/vim/vim


Commit MetaInfo

Révisionbe81baeb69f8abd67575ea4164866bf9ab8db96c (tree)
l'heure2020-01-24 05:00:03
AuteurBram Moolenaar <Bram@vim....>
CommiterBram Moolenaar

Message de Log

patch 8.2.0147: block Visual mode operators not correct when 'linebreak' set

Commit: https://github.com/vim/vim/commit/03c3bd9fd094c1aede2e8fe3ad8fd25b9f033053
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Jan 23 20:58:09 2020 +0100

patch 8.2.0147: block Visual mode operators not correct when 'linebreak' set
Problem: Block Visual mode operators not correct when 'linebreak' set.
Solution: Set w_p_lbr to lbr_saved more often. (Ken Takata, closes https://github.com/vim/vim/issues/5524)

Change Summary

Modification

diff -r eded52b4666b -r be81baeb69f8 src/ops.c
--- a/src/ops.c Thu Jan 23 20:00:05 2020 +0100
+++ b/src/ops.c Thu Jan 23 21:00:03 2020 +0100
@@ -2744,7 +2744,12 @@
27442744 char_u *line;
27452745 char_u *prev_pstart;
27462746 char_u *prev_pend;
2747-
2747+#ifdef FEAT_LINEBREAK
2748+ int lbr_saved = curwin->w_p_lbr;
2749+
2750+ // Avoid a problem with unwanted linebreaks in block mode.
2751+ curwin->w_p_lbr = FALSE;
2752+#endif
27482753 bdp->startspaces = 0;
27492754 bdp->endspaces = 0;
27502755 bdp->textlen = 0;
@@ -2863,6 +2868,9 @@
28632868 }
28642869 bdp->textcol = (colnr_T) (pstart - line);
28652870 bdp->textstart = pstart;
2871+#ifdef FEAT_LINEBREAK
2872+ curwin->w_p_lbr = lbr_saved;
2873+#endif
28662874 }
28672875
28682876 /*
@@ -4556,11 +4564,7 @@
45564564 #ifdef FEAT_LINEBREAK
45574565 // Restore linebreak, so that when the user edits it looks as
45584566 // before.
4559- if (curwin->w_p_lbr != lbr_saved)
4560- {
4561- curwin->w_p_lbr = lbr_saved;
4562- get_op_vcol(oap, redo_VIsual_mode, FALSE);
4563- }
4567+ curwin->w_p_lbr = lbr_saved;
45644568 #endif
45654569 // Reset finish_op now, don't want it set inside edit().
45664570 finish_op = FALSE;
@@ -4663,11 +4667,7 @@
46634667 #ifdef FEAT_LINEBREAK
46644668 // Restore linebreak, so that when the user edits it looks as
46654669 // before.
4666- if (curwin->w_p_lbr != lbr_saved)
4667- {
4668- curwin->w_p_lbr = lbr_saved;
4669- get_op_vcol(oap, redo_VIsual_mode, FALSE);
4670- }
4670+ curwin->w_p_lbr = lbr_saved;
46714671 #endif
46724672 op_insert(oap, cap->count1);
46734673 #ifdef FEAT_LINEBREAK
@@ -4698,11 +4698,7 @@
46984698 #ifdef FEAT_LINEBREAK
46994699 // Restore linebreak, so that when the user edits it looks as
47004700 // before.
4701- if (curwin->w_p_lbr != lbr_saved)
4702- {
4703- curwin->w_p_lbr = lbr_saved;
4704- get_op_vcol(oap, redo_VIsual_mode, FALSE);
4705- }
4701+ curwin->w_p_lbr = lbr_saved;
47064702 #endif
47074703 op_replace(oap, cap->nchar);
47084704 }
diff -r eded52b4666b -r be81baeb69f8 src/testdir/test_listlbr.vim
--- a/src/testdir/test_listlbr.vim Thu Jan 23 20:00:05 2020 +0100
+++ b/src/testdir/test_listlbr.vim Thu Jan 23 21:00:03 2020 +0100
@@ -100,6 +100,37 @@
100100 call s:close_windows()
101101 endfunc
102102
103+func Test_linebreak_with_visual_operations()
104+ call s:test_windows()
105+ let line = '1234567890 2234567890 3234567890'
106+ call setline(1, line)
107+
108+ " yank
109+ exec "norm! ^w\<C-V>ey"
110+ call assert_equal('2234567890', @@)
111+ exec "norm! w\<C-V>ey"
112+ call assert_equal('3234567890', @@)
113+
114+ " increment / decrement
115+ exec "norm! ^w\<C-V>\<C-A>w\<C-V>\<C-X>"
116+ call assert_equal('1234567890 3234567890 2234567890', getline(1))
117+
118+ " replace
119+ exec "norm! ^w\<C-V>3lraw\<C-V>3lrb"
120+ call assert_equal('1234567890 aaaa567890 bbbb567890', getline(1))
121+
122+ " tilde
123+ exec "norm! ^w\<C-V>2l~w\<C-V>2l~"
124+ call assert_equal('1234567890 AAAa567890 BBBb567890', getline(1))
125+
126+ " delete and insert
127+ exec "norm! ^w\<C-V>3lc2345\<Esc>w\<C-V>3lc3456\<Esc>"
128+ call assert_equal('1234567890 2345567890 3456567890', getline(1))
129+ call assert_equal('BBBb', @@)
130+
131+ call s:close_windows()
132+endfunc
133+
103134 func Test_virtual_block()
104135 call s:test_windows('setl sbr=+')
105136 call setline(1, [
diff -r eded52b4666b -r be81baeb69f8 src/version.c
--- a/src/version.c Thu Jan 23 20:00:05 2020 +0100
+++ b/src/version.c Thu Jan 23 21:00:03 2020 +0100
@@ -743,6 +743,8 @@
743743 static int included_patches[] =
744744 { /* Add new patch number below this line */
745745 /**/
746+ 147,
747+/**/
746748 146,
747749 /**/
748750 145,
Afficher sur ancien navigateur de dépôt.