mirror of
https://github.com/neovim/neovim.git
synced 2025-09-20 18:28:19 +00:00
vim-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 vim/vim#5524)
03c3bd9fd0
This commit is contained in:
@@ -1846,10 +1846,7 @@ void do_pending_operator(cmdarg_T *cap, int old_col, bool gui_yank)
|
|||||||
restart_edit = 0;
|
restart_edit = 0;
|
||||||
|
|
||||||
// Restore linebreak, so that when the user edits it looks as before.
|
// Restore linebreak, so that when the user edits it looks as before.
|
||||||
if (curwin->w_p_lbr != lbr_saved) {
|
|
||||||
curwin->w_p_lbr = lbr_saved;
|
curwin->w_p_lbr = lbr_saved;
|
||||||
get_op_vcol(oap, redo_VIsual_mode, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Reset finish_op now, don't want it set inside edit().
|
// Reset finish_op now, don't want it set inside edit().
|
||||||
finish_op = false;
|
finish_op = false;
|
||||||
@@ -1935,10 +1932,7 @@ void do_pending_operator(cmdarg_T *cap, int old_col, bool gui_yank)
|
|||||||
restart_edit = 0;
|
restart_edit = 0;
|
||||||
|
|
||||||
// Restore linebreak, so that when the user edits it looks as before.
|
// Restore linebreak, so that when the user edits it looks as before.
|
||||||
if (curwin->w_p_lbr != lbr_saved) {
|
|
||||||
curwin->w_p_lbr = lbr_saved;
|
curwin->w_p_lbr = lbr_saved;
|
||||||
get_op_vcol(oap, redo_VIsual_mode, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
op_insert(oap, cap->count1);
|
op_insert(oap, cap->count1);
|
||||||
|
|
||||||
@@ -1964,10 +1958,7 @@ void do_pending_operator(cmdarg_T *cap, int old_col, bool gui_yank)
|
|||||||
CancelRedo();
|
CancelRedo();
|
||||||
} else {
|
} else {
|
||||||
// Restore linebreak, so that when the user edits it looks as before.
|
// Restore linebreak, so that when the user edits it looks as before.
|
||||||
if (curwin->w_p_lbr != lbr_saved) {
|
|
||||||
curwin->w_p_lbr = lbr_saved;
|
curwin->w_p_lbr = lbr_saved;
|
||||||
get_op_vcol(oap, redo_VIsual_mode, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
op_replace(oap, cap->nchar);
|
op_replace(oap, cap->nchar);
|
||||||
}
|
}
|
||||||
|
@@ -4414,7 +4414,10 @@ static void block_prep(oparg_T *oap, struct block_def *bdp, linenr_T lnum,
|
|||||||
char_u *line;
|
char_u *line;
|
||||||
char_u *prev_pstart;
|
char_u *prev_pstart;
|
||||||
char_u *prev_pend;
|
char_u *prev_pend;
|
||||||
|
const int lbr_saved = curwin->w_p_lbr;
|
||||||
|
|
||||||
|
// Avoid a problem with unwanted linebreaks in block mode.
|
||||||
|
curwin->w_p_lbr = false;
|
||||||
bdp->startspaces = 0;
|
bdp->startspaces = 0;
|
||||||
bdp->endspaces = 0;
|
bdp->endspaces = 0;
|
||||||
bdp->textlen = 0;
|
bdp->textlen = 0;
|
||||||
@@ -4514,6 +4517,7 @@ static void block_prep(oparg_T *oap, struct block_def *bdp, linenr_T lnum,
|
|||||||
}
|
}
|
||||||
bdp->textcol = (colnr_T) (pstart - line);
|
bdp->textcol = (colnr_T) (pstart - line);
|
||||||
bdp->textstart = pstart;
|
bdp->textstart = pstart;
|
||||||
|
curwin->w_p_lbr = lbr_saved;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Handle the add/subtract operator.
|
/// Handle the add/subtract operator.
|
||||||
|
@@ -103,6 +103,37 @@ func Test_linebreak_with_conceal()
|
|||||||
call s:close_windows()
|
call s:close_windows()
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_linebreak_with_visual_operations()
|
||||||
|
call s:test_windows()
|
||||||
|
let line = '1234567890 2234567890 3234567890'
|
||||||
|
call setline(1, line)
|
||||||
|
|
||||||
|
" yank
|
||||||
|
exec "norm! ^w\<C-V>ey"
|
||||||
|
call assert_equal('2234567890', @@)
|
||||||
|
exec "norm! w\<C-V>ey"
|
||||||
|
call assert_equal('3234567890', @@)
|
||||||
|
|
||||||
|
" increment / decrement
|
||||||
|
exec "norm! ^w\<C-V>\<C-A>w\<C-V>\<C-X>"
|
||||||
|
call assert_equal('1234567890 3234567890 2234567890', getline(1))
|
||||||
|
|
||||||
|
" replace
|
||||||
|
exec "norm! ^w\<C-V>3lraw\<C-V>3lrb"
|
||||||
|
call assert_equal('1234567890 aaaa567890 bbbb567890', getline(1))
|
||||||
|
|
||||||
|
" tilde
|
||||||
|
exec "norm! ^w\<C-V>2l~w\<C-V>2l~"
|
||||||
|
call assert_equal('1234567890 AAAa567890 BBBb567890', getline(1))
|
||||||
|
|
||||||
|
" delete and insert
|
||||||
|
exec "norm! ^w\<C-V>3lc2345\<Esc>w\<C-V>3lc3456\<Esc>"
|
||||||
|
call assert_equal('1234567890 2345567890 3456567890', getline(1))
|
||||||
|
call assert_equal('BBBb', @@)
|
||||||
|
|
||||||
|
call s:close_windows()
|
||||||
|
endfunc
|
||||||
|
|
||||||
func Test_virtual_block()
|
func Test_virtual_block()
|
||||||
call s:test_windows('setl sbr=+')
|
call s:test_windows('setl sbr=+')
|
||||||
call setline(1, [
|
call setline(1, [
|
||||||
|
Reference in New Issue
Block a user