aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbfredl <bjorn.linse@gmail.com>2022-01-27 13:44:30 +0100
committerGitHub <noreply@github.com>2022-01-27 13:44:30 +0100
commita47fdf8421142532d27354f58109da220c45a5fb (patch)
tree527a6e01b8c90e7856cb4f66d8bfd9882cf6191d /src
parent7ea09dde5f0044e8a264cc2617f0a58a5684c57c (diff)
parentf2d84df4a856810276eb83b08d5c51d5c6407374 (diff)
downloadrneovim-a47fdf8421142532d27354f58109da220c45a5fb.tar.gz
rneovim-a47fdf8421142532d27354f58109da220c45a5fb.tar.bz2
rneovim-a47fdf8421142532d27354f58109da220c45a5fb.zip
Merge pull request #17175 from zeertzjq/vim-8.2.3095
vim-patch:8.2.3095: with 'virtualedit' set to "block" block selection is wrong
Diffstat (limited to 'src')
-rw-r--r--src/nvim/screen.c27
-rw-r--r--src/nvim/testdir/test_visual.vim3
2 files changed, 27 insertions, 3 deletions
diff --git a/src/nvim/screen.c b/src/nvim/screen.c
index 7e7b34fb14..af023d6785 100644
--- a/src/nvim/screen.c
+++ b/src/nvim/screen.c
@@ -1222,12 +1222,33 @@ static void win_update(win_T *wp, Providers *providers)
}
getvcols(wp, &VIsual, &curwin->w_cursor, &fromc, &toc);
- curwin->w_ve_flags = save_ve_flags;
toc++;
+ curwin->w_ve_flags = save_ve_flags;
// Highlight to the end of the line, unless 'virtualedit' has
// "block".
- if (curwin->w_curswant == MAXCOL && !(get_ve_flags() & VE_BLOCK)) {
- toc = MAXCOL;
+ if (curwin->w_curswant == MAXCOL) {
+ if (get_ve_flags() & VE_BLOCK) {
+ pos_T pos;
+ int cursor_above = curwin->w_cursor.lnum < VIsual.lnum;
+
+ // Need to find the longest line.
+ toc = 0;
+ pos.coladd = 0;
+ for (pos.lnum = curwin->w_cursor.lnum;
+ cursor_above ? pos.lnum <= VIsual.lnum : pos.lnum >= VIsual.lnum;
+ pos.lnum += cursor_above ? 1 : -1) {
+ colnr_T t;
+
+ pos.col = STRLEN(ml_get_buf(wp->w_buffer, pos.lnum, false));
+ getvvcol(wp, &pos, NULL, NULL, &t);
+ if (toc < t) {
+ toc = t;
+ }
+ }
+ toc++;
+ } else {
+ toc = MAXCOL;
+ }
}
if (fromc != wp->w_old_cursor_fcol
diff --git a/src/nvim/testdir/test_visual.vim b/src/nvim/testdir/test_visual.vim
index b087c88c35..76274fb038 100644
--- a/src/nvim/testdir/test_visual.vim
+++ b/src/nvim/testdir/test_visual.vim
@@ -1124,6 +1124,9 @@ func Test_visual_block_with_virtualedit()
call term_sendkeys(buf, "\<C-V>gg$")
call VerifyScreenDump(buf, 'Test_visual_block_with_virtualedit', {})
+ call term_sendkeys(buf, "\<Esc>gg\<C-V>G$")
+ call VerifyScreenDump(buf, 'Test_visual_block_with_virtualedit2', {})
+
" clean up
call term_sendkeys(buf, "\<Esc>")
call StopVimInTerminal(buf)