diff options
author | zeertzjq <zeertzjq@outlook.com> | 2024-01-26 07:37:04 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-26 07:37:04 +0800 |
commit | 6116495e6e6d3508eb99720faad7e55ba7cbe978 (patch) | |
tree | 8eca83450056f36886aff09bbdc293692b596961 /src | |
parent | 83b51b36aa46d4bb25fada6eda22102e0aa5ef19 (diff) | |
parent | c5a7df79a7692c044cb69e38c7c6b71f44d4656d (diff) | |
download | rneovim-6116495e6e6d3508eb99720faad7e55ba7cbe978.tar.gz rneovim-6116495e6e6d3508eb99720faad7e55ba7cbe978.tar.bz2 rneovim-6116495e6e6d3508eb99720faad7e55ba7cbe978.zip |
Merge pull request #27201 from zeertzjq/vim-9.1.0054
vim-patch:9.1.{0054,0056}
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/plines.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/src/nvim/plines.c b/src/nvim/plines.c index 678752eae5..f3db2603d2 100644 --- a/src/nvim/plines.c +++ b/src/nvim/plines.c @@ -277,22 +277,20 @@ CharSize charsize_regular(CharsizeArg *csarg, char *const cur, colnr_T const vco size += added; } - char *s = cur; - colnr_T vcol_start = 0; // start from where to consider linebreak + bool need_lbr = false; // If 'linebreak' set check at a blank before a non-blank if the line - // needs a break here - if (wp->w_p_lbr && wp->w_p_wrap && wp->w_width_inner != 0) { + // needs a break here. + if (wp->w_p_lbr && wp->w_p_wrap && wp->w_width_inner != 0 + && vim_isbreak((uint8_t)cur[0]) && !vim_isbreak((uint8_t)cur[1])) { char *t = csarg->line; while (vim_isbreak((uint8_t)t[0])) { t++; } - vcol_start = (colnr_T)(t - csarg->line); + // 'linebreak' is only needed when not in leading whitespace. + need_lbr = cur >= t; } - if (wp->w_p_lbr && vcol_start <= vcol - && vim_isbreak((uint8_t)s[0]) - && !vim_isbreak((uint8_t)s[1]) - && wp->w_p_wrap - && wp->w_width_inner != 0) { + if (need_lbr) { + char *s = cur; // Count all characters from first non-blank after a blank up to next // non-blank after a blank. int numberextra = win_col_off(wp); |