diff options
-rw-r--r-- | src/nvim/plines.c | 18 | ||||
-rw-r--r-- | test/old/testdir/test_listlbr.vim | 8 | ||||
-rw-r--r-- | test/old/testdir/test_put.vim | 10 |
3 files changed, 22 insertions, 14 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); diff --git a/test/old/testdir/test_listlbr.vim b/test/old/testdir/test_listlbr.vim index 6dea94fbf1..e9bf9f3ff2 100644 --- a/test/old/testdir/test_listlbr.vim +++ b/test/old/testdir/test_listlbr.vim @@ -375,13 +375,13 @@ endfunc func Test_linebreak_no_break_after_whitespace_only() call s:test_windows('setl ts=4 linebreak wrap') - call setline(1, "\tabcdefghijklmnopqrstuvwxyz" .. + call setline(1, "\t abcdefghijklmnopqrstuvwxyz" .. \ "abcdefghijklmnopqrstuvwxyz") let lines = s:screen_lines([1, 4], winwidth(0)) let expect = [ -\ " abcdefghijklmnop", -\ "qrstuvwxyzabcdefghij", -\ "klmnopqrstuvwxyz ", +\ " abcdefghijklmn", +\ "opqrstuvwxyzabcdefgh", +\ "ijklmnopqrstuvwxyz ", \ "~ ", \ ] call s:compare_lines(expect, lines) diff --git a/test/old/testdir/test_put.vim b/test/old/testdir/test_put.vim index 6c4bd28386..69fd4643c1 100644 --- a/test/old/testdir/test_put.vim +++ b/test/old/testdir/test_put.vim @@ -12,6 +12,16 @@ func Test_put_block() bwipe! endfunc +func Test_put_block_unicode() + new + call setreg('a', "À\nÀÀ\naaaaaaaaaaaa", "\<C-V>") + call setline(1, [' 1', ' 2', ' 3']) + exe "norm! \<C-V>jj\"ap" + let expected = ['À 1', 'ÀÀ 2', 'aaaaaaaaaaaa3'] + call assert_equal(expected, getline(1, 3)) + bw! +endfunc + func Test_put_char_block() new call setline(1, ['Line 1', 'Line 2']) |