Mercurial > vim
comparison src/drawscreen.c @ 25116:56817e74d106 v8.2.3095
patch 8.2.3095: with 'virtualedit' set to "block" block selection is wrong
Commit: https://github.com/vim/vim/commit/b17ab86e7b8712206aa9ea7198c28db969e25936
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Jul 3 22:15:17 2021 +0200
patch 8.2.3095: with 'virtualedit' set to "block" block selection is wrong
Problem: With 'virtualedit' set to "block" block selection is wrong after
using "$". (Marco Trosi)
Solution: Compute the longest selected line. (closes #8495)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 03 Jul 2021 22:30:03 +0200 |
parents | febccc86897e |
children | f60fa4221b11 |
comparison
equal
deleted
inserted
replaced
25115:9ca1b31f6297 | 25116:56817e74d106 |
---|---|
2007 | 2007 |
2008 if (curwin->w_p_lbr) | 2008 if (curwin->w_p_lbr) |
2009 ve_flags = VE_ALL; | 2009 ve_flags = VE_ALL; |
2010 #endif | 2010 #endif |
2011 getvcols(wp, &VIsual, &curwin->w_cursor, &fromc, &toc); | 2011 getvcols(wp, &VIsual, &curwin->w_cursor, &fromc, &toc); |
2012 ++toc; | |
2012 #if defined(FEAT_LINEBREAK) | 2013 #if defined(FEAT_LINEBREAK) |
2013 ve_flags = save_ve_flags; | 2014 ve_flags = save_ve_flags; |
2014 #endif | 2015 #endif |
2015 ++toc; | |
2016 // Highlight to the end of the line, unless 'virtualedit' has | 2016 // Highlight to the end of the line, unless 'virtualedit' has |
2017 // "block". | 2017 // "block". |
2018 if (curwin->w_curswant == MAXCOL && !(ve_flags & VE_BLOCK)) | 2018 if (curwin->w_curswant == MAXCOL) |
2019 toc = MAXCOL; | 2019 { |
2020 if (ve_flags & VE_BLOCK) | |
2021 { | |
2022 pos_T pos; | |
2023 int cursor_above = | |
2024 curwin->w_cursor.lnum < VIsual.lnum; | |
2025 | |
2026 // Need to find the longest line. | |
2027 toc = 0; | |
2028 pos.coladd = 0; | |
2029 for (pos.lnum = curwin->w_cursor.lnum; cursor_above | |
2030 ? pos.lnum <= VIsual.lnum | |
2031 : pos.lnum >= VIsual.lnum; | |
2032 pos.lnum += cursor_above ? 1 : -1) | |
2033 { | |
2034 colnr_T t; | |
2035 | |
2036 pos.col = STRLEN(ml_get_buf(wp->w_buffer, | |
2037 pos.lnum, FALSE)); | |
2038 getvvcol(wp, &pos, NULL, NULL, &t); | |
2039 if (toc < t) | |
2040 toc = t; | |
2041 } | |
2042 ++toc; | |
2043 } | |
2044 else | |
2045 toc = MAXCOL; | |
2046 } | |
2020 | 2047 |
2021 if (fromc != wp->w_old_cursor_fcol | 2048 if (fromc != wp->w_old_cursor_fcol |
2022 || toc != wp->w_old_cursor_lcol) | 2049 || toc != wp->w_old_cursor_lcol) |
2023 { | 2050 { |
2024 if (from > VIsual.lnum) | 2051 if (from > VIsual.lnum) |