aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/nvim/charset.c1
-rw-r--r--src/nvim/option.c5
-rw-r--r--src/nvim/screen.c66
-rw-r--r--src/nvim/testdir/test_listlbr.in62
-rw-r--r--src/nvim/testdir/test_listlbr.ok39
-rw-r--r--src/nvim/version.c6
6 files changed, 164 insertions, 15 deletions
diff --git a/src/nvim/charset.c b/src/nvim/charset.c
index 3392cceb9f..955f101a61 100644
--- a/src/nvim/charset.c
+++ b/src/nvim/charset.c
@@ -997,7 +997,6 @@ int win_lbr_chartabsize(win_T *wp, char_u *line, char_u *s, colnr_T col, int *he
if (wp->w_p_lbr
&& vim_isbreak(c)
&& !vim_isbreak(s[1])
- && !wp->w_p_list
&& wp->w_p_wrap
&& (wp->w_width != 0)) {
// Count all characters from first non-blank after a blank up to next
diff --git a/src/nvim/option.c b/src/nvim/option.c
index 7d40fb3d6b..a878ba6455 100644
--- a/src/nvim/option.c
+++ b/src/nvim/option.c
@@ -8157,9 +8157,10 @@ void find_mps_values(int *initc, int *findc, int *backwards, int switchit)
}
}
-/* This is called when 'breakindentopt' is changed and whenn a window is
+/* This is called when 'breakindentopt' is changed and when a window is
initialized */
-int briopt_check() {
+int briopt_check(void)
+{
char_u *p;
int bri_shift = 0;
long bri_min = 20;
diff --git a/src/nvim/screen.c b/src/nvim/screen.c
index 61e783f2b1..f6ee877a66 100644
--- a/src/nvim/screen.c
+++ b/src/nvim/screen.c
@@ -2197,6 +2197,7 @@ win_line (
char_u extra[18]; /* line number and 'fdc' must fit in here */
int n_extra = 0; /* number of extra chars */
char_u *p_extra = NULL; /* string of extra chars, plus NUL */
+ char_u *p_extra_free = NULL; /* p_extra needs to be freed */
int c_extra = NUL; /* extra chars, all the same */
int extra_attr = 0; /* attributes when n_extra != 0 */
static char_u *at_end_str = (char_u *)""; /* used for p_extra when
@@ -3108,6 +3109,10 @@ win_line (
}
--n_extra;
} else {
+ if (p_extra_free != NULL) {
+ free(p_extra_free);
+ p_extra_free = NULL;
+ }
/*
* Get a character from the line itself.
*/
@@ -3408,19 +3413,20 @@ win_line (
/*
* Found last space before word: check for line break.
*/
- if (wp->w_p_lbr && vim_isbreak(c) && !vim_isbreak(*ptr)
- && !wp->w_p_list) {
+ if (wp->w_p_lbr && vim_isbreak(c) && !vim_isbreak(*ptr)) {
char_u *p = ptr - (
has_mbyte ? mb_l :
1);
// TODO: is passing p for start of the line OK?
- n_extra = win_lbr_chartabsize(wp, p, p, (colnr_T)vcol, NULL) - 1;
+ n_extra = win_lbr_chartabsize(wp, line, p, (colnr_T)vcol, NULL) - 1;
c_extra = ' ';
if (vim_iswhite(c)) {
if (c == TAB)
/* See "Tab alignment" below. */
FIX_FOR_BOGUSCOLS;
- c = ' ';
+ if (!wp->w_p_list) {
+ c = ' ';
+ }
}
}
@@ -3451,9 +3457,36 @@ win_line (
* into "ScreenLines".
*/
if (c == TAB && (!wp->w_p_list || lcs_tab1)) {
+ int tab_len = 0;
/* tab amount depends on current column */
- n_extra = (int)wp->w_buffer->b_p_ts
+ tab_len = (int)wp->w_buffer->b_p_ts
- vcol % (int)wp->w_buffer->b_p_ts - 1;
+ if (!wp->w_p_lbr) {
+ n_extra = tab_len;
+ } else {
+ char_u *p;
+ int len = n_extra;
+ int i;
+ int saved_nextra = n_extra;
+
+ /* if n_extra > 0, it gives the number of chars to use for
+ * a tab, else we need to calculate the width for a tab */
+ len = (tab_len * mb_char2len(lcs_tab2));
+ if (n_extra > 0) {
+ len += n_extra - tab_len;
+ }
+ c = lcs_tab1;
+ p = xmalloc(len + 1);
+ memset(p, ' ', len);
+ p[len] = NUL;
+ p_extra_free = p;
+ for (i = 0; i < tab_len; i++) {
+ mb_char2bytes(lcs_tab2, p);
+ p += mb_char2len(lcs_tab2);
+ n_extra += mb_char2len(lcs_tab2) - (saved_nextra > 0 ? 1: 0);
+ }
+ p_extra = p_extra_free;
+ }
/* Tab alignment should be identical regardless of
* 'conceallevel' value. So tab compensates of all
* previous concealed characters, and thus resets vcol_off
@@ -3464,8 +3497,12 @@ win_line (
mb_utf8 = FALSE; /* don't draw as UTF-8 */
if (wp->w_p_list) {
c = lcs_tab1;
- c_extra = lcs_tab2;
- n_attr = n_extra + 1;
+ if (wp->w_p_lbr) {
+ c_extra = NUL; /* using p_extra from above */
+ } else {
+ c_extra = lcs_tab2;
+ }
+ n_attr = tab_len + 1;
extra_attr = hl_attr(HLF_8);
saved_attr2 = char_attr; /* save current attr */
mb_c = c;
@@ -3527,9 +3564,20 @@ win_line (
p_extra = transchar(c);
if ((dy_flags & DY_UHEX) && wp->w_p_rl)
rl_mirror(p_extra); /* reverse "<12>" */
- n_extra = byte2cells(c) - 1;
c_extra = NUL;
- c = *p_extra++;
+ if (wp->w_p_lbr) {
+ char_u *p;
+
+ c = *p_extra;
+ p = xmalloc(n_extra + 1);
+ memset(p, ' ', n_extra);
+ STRNCPY(p, p_extra + 1, STRLEN(p_extra) - 1);
+ p[n_extra] = NUL;
+ p_extra_free = p_extra = p;
+ } else {
+ n_extra = byte2cells(c) - 1;
+ c = *p_extra++;
+ }
if (!attr_pri) {
n_attr = n_extra + 1;
extra_attr = hl_attr(HLF_8);
diff --git a/src/nvim/testdir/test_listlbr.in b/src/nvim/testdir/test_listlbr.in
new file mode 100644
index 0000000000..0d50d4b060
--- /dev/null
+++ b/src/nvim/testdir/test_listlbr.in
@@ -0,0 +1,62 @@
+Test for linebreak and list option
+
+STARTTEST
+:so small.vim
+:if !exists("+linebreak") | e! test.ok | w! test.out | qa! | endif
+:10new|:vsp|:vert resize 20
+:put =\"\tabcdef hijklmn\tpqrstuvwxyz\u00a01060ABCDEFGHIJKLMNOP \"
+:norm! zt
+:set ts=4 sw=4 sts=4 linebreak sbr=+ wrap
+:fu! ScreenChar(width)
+: let c=''
+: for j in range(1,4)
+: for i in range(1,a:width)
+: let c.=nr2char(screenchar(j, i))
+: endfor
+: let c.="\n"
+: endfor
+: return c
+:endfu
+:fu! DoRecordScreen()
+: wincmd l
+: $put =printf(\"\n%s\", g:test)
+: $put =g:line
+: wincmd p
+:endfu
+:let g:test="Test 1: set linebreak"
+:redraw!
+:let line=ScreenChar(winwidth(0))
+:call DoRecordScreen()
+:let g:test="Test 2: set linebreak + set list"
+:set linebreak list listchars=
+:redraw!
+:let line=ScreenChar(winwidth(0))
+:call DoRecordScreen()
+:let g:test ="Test 3: set linebreak + set list + fancy listchars"
+:exe "set linebreak list listchars=nbsp:\u2423,tab:\u2595\u2014,trail:\u02d1,eol:\ub6"
+:redraw!
+:let line=ScreenChar(winwidth(0))
+:call DoRecordScreen()
+:let g:test ="Test 4: set linebreak nolist"
+:set nolist linebreak
+:redraw!
+:let line=ScreenChar(winwidth(0))
+:call DoRecordScreen()
+:let g:test ="Test 5: set nolinebreak list"
+:set list nolinebreak
+:redraw!
+:let line=ScreenChar(winwidth(0))
+:call DoRecordScreen()
+:let g:test ="Test 6: set linebreak with tab and 1 line as long as screen: should break!"
+:set nolist linebreak ts=8
+:let line="1\t".repeat('a', winwidth(0)-2)
+:$put =line
+:$
+:norm! zt
+:redraw!
+:let line=ScreenChar(winwidth(0))
+:call DoRecordScreen()
+:%w! test.out
+:qa!
+ENDTEST
+dummy text
diff --git a/src/nvim/testdir/test_listlbr.ok b/src/nvim/testdir/test_listlbr.ok
new file mode 100644
index 0000000000..f391d50aea
--- /dev/null
+++ b/src/nvim/testdir/test_listlbr.ok
@@ -0,0 +1,39 @@
+
+ abcdef hijklmn pqrstuvwxyz 1060ABCDEFGHIJKLMNOP
+
+Test 1: set linebreak
+ abcdef
++hijklmn
++pqrstuvwxyz 1060ABC
++DEFGHIJKLMNOP
+
+Test 2: set linebreak + set list
+^Iabcdef hijklmn^I
++pqrstuvwxyz 1060ABC
++DEFGHIJKLMNOP
+
+
+Test 3: set linebreak + set list + fancy listchars
+▕———abcdef
++hijklmn▕———
++pqrstuvwxyz␣1060ABC
++DEFGHIJKLMNOPˑ¶
+
+Test 4: set linebreak nolist
+ abcdef
++hijklmn
++pqrstuvwxyz 1060ABC
++DEFGHIJKLMNOP
+
+Test 5: set nolinebreak list
+▕———abcdef hijklmn▕—
++pqrstuvwxyz␣1060ABC
++DEFGHIJKLMNOPˑ¶
+1 aaaaaaaaaaaaaaaaaa
+
+Test 6: set linebreak with tab and 1 line as long as screen: should break!
+1
++aaaaaaaaaaaaaaaaaa
+~
+~
diff --git a/src/nvim/version.c b/src/nvim/version.c
index 6e503200f0..6ec6bc0b7e 100644
--- a/src/nvim/version.c
+++ b/src/nvim/version.c
@@ -242,14 +242,14 @@ static int included_patches[] = {
//356 NA
//355,
//354,
- //353,
+ 353,
//352,
//351,
//350,
//349,
//348,
//347,
- //346,
+ 346,
//345,
//344,
//343,
@@ -257,7 +257,7 @@ static int included_patches[] = {
//341,
//340 NA
//339,
- //338,
+ 338,
//337,
//336,
335,