diff options
author | watiko <service@mail.watiko.net> | 2016-01-14 20:41:22 +0900 |
---|---|---|
committer | watiko <service@mail.watiko.net> | 2016-02-01 03:43:37 +0900 |
commit | 43fd12629841d459214ead194410d317ef06006c (patch) | |
tree | 074740a72dbbcc9518b2d6bc34458f3b1a298690 /src/nvim/normal.c | |
parent | b20b8f9f0450e0a3188f2f1c89d575399e0ab9a6 (diff) | |
download | rneovim-43fd12629841d459214ead194410d317ef06006c.tar.gz rneovim-43fd12629841d459214ead194410d317ef06006c.tar.bz2 rneovim-43fd12629841d459214ead194410d317ef06006c.zip |
vim-patch:7.4.782
Problem: Still a few problems with CTRL-A and CTRL-X in Visual mode.
Solution: Fix the reported problems. (Christian Brabandt)
https://github.com/vim/vim/commit/5d1bc78a2b9fbe3e3112afcde7c80eb19d5989f4
Diffstat (limited to 'src/nvim/normal.c')
-rw-r--r-- | src/nvim/normal.c | 43 |
1 files changed, 33 insertions, 10 deletions
diff --git a/src/nvim/normal.c b/src/nvim/normal.c index d831679b64..23e2e634cc 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -3028,6 +3028,34 @@ size_t find_ident_at_pos(win_T *wp, linenr_T lnum, colnr_T startcol, return (size_t)col; } +// Add commands to reselect Visual mode into the redo buffer. +static void prep_redo_visual(cmdarg_T *cap) +{ + ResetRedobuff(); + AppendCharToRedobuff(VIsual_mode); + if (VIsual_mode == 'V' && + curbuf->b_visual.vi_end.lnum != curbuf->b_visual.vi_start.lnum) { + AppendNumberToRedobuff(curbuf->b_visual.vi_end.lnum - + curbuf->b_visual.vi_start.lnum); + AppendCharToRedobuff('j'); + } else if (VIsual_mode == 'v' || VIsual_mode == Ctrl_V) { + // block visual mode or char visual mmode + if (curbuf->b_visual.vi_end.lnum != curbuf->b_visual.vi_start.lnum) { + AppendNumberToRedobuff(curbuf->b_visual.vi_end.lnum - + curbuf->b_visual.vi_start.lnum); + AppendCharToRedobuff('j'); + } + if (curbuf->b_visual.vi_curswant == MAXCOL) { + AppendCharToRedobuff('$'); + } else if (curbuf->b_visual.vi_end.col > curbuf->b_visual.vi_start.col) { + AppendNumberToRedobuff(curbuf->b_visual.vi_end.col - + curbuf->b_visual.vi_start.col - 1); + AppendCharToRedobuff(' '); + } + } + AppendNumberToRedobuff(cap->count1); +} + /* * Prepare for redo of a normal command. */ @@ -3507,15 +3535,9 @@ static void nv_addsub(cmdarg_T *cap) if (cap->oap->op_type == OP_NOP && do_addsub((int)cap->cmdchar, cap->count1, cap->arg) == OK) { if (visual) { - ResetRedobuff(); - AppendCharToRedobuff(VIsual_mode); - if (VIsual_mode == 'V') { - AppendNumberToRedobuff(cap->oap->line_count); - AppendCharToRedobuff('j'); - } - AppendNumberToRedobuff(cap->count1); - if (cap->nchar != NUL) { - AppendCharToRedobuff(cap->nchar); + prep_redo_visual(cap); + if (cap->arg) { + AppendCharToRedobuff('g'); } AppendCharToRedobuff(cap->cmdchar); } else { @@ -3526,7 +3548,8 @@ static void nv_addsub(cmdarg_T *cap) } if (visual) { VIsual_active = false; - redraw_later(CLEAR); + redo_VIsual_busy = false; + redraw_later(INVERTED); } } |