diff options
author | Christian Brabandt <cb@256bit.org> | 2024-04-27 11:55:08 +0200 |
---|---|---|
committer | Christian Brabandt <cb@256bit.org> | 2024-04-27 11:55:08 +0200 |
commit | 86ef815959d18961a3d21cee07ab724e618d3a7b (patch) | |
tree | b5039a1ec7ad36b69e101b52645040b88a2e929b | |
parent | 92917069b1a89e0e6c253a585dfe0a19cc2c0699 (diff) |
patch 9.1.0377: Formatting text wrong when 'breakindent' is setv9.1.0377
Problem: formatting text wrong when 'breakindent' is set
(Gary Johnson)
Solution: temporarily disable 'breakindent' option when formatting text,
so that the breakindent is not wrongly taken into account for
the line length
fixes: #14630
closes: #14637
Signed-off-by: Christian Brabandt <cb@256bit.org>
-rw-r--r-- | src/testdir/test_textformat.vim | 24 | ||||
-rw-r--r-- | src/textformat.c | 3 | ||||
-rw-r--r-- | src/version.c | 2 |
3 files changed, 29 insertions, 0 deletions
diff --git a/src/testdir/test_textformat.vim b/src/testdir/test_textformat.vim index a9cffd0e6f..5d584867a7 100644 --- a/src/testdir/test_textformat.vim +++ b/src/testdir/test_textformat.vim @@ -1312,4 +1312,28 @@ func Test_textwdith_overflow() bw! endfunc +func Test_breakindent_reformat() + " Make sure textformatting uses the full width + " of the textwidth and does not consider the indent + " from breakindent into account when calculating the + " line length. Should break at tw 78 and not at 70 + CheckOption breakindent + new + 80vnew + 39vnew + setl ai breakindent tw=78 + let lorem = [ + \ ' Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam luctus', + \ ' lectus sodales, dictum augue vel, molestie augue. Duis sit amet', + \ ' rhoncus justo. Nullam posuere risus semper magna commodo scelerisque.', + \ ' Duis et venenatis sem. In rhoncus augue sed tempor mattis. Mauris id', + \ ' aliquet odio.'] + call setline(1, lorem) + norm! gqap + call assert_equal(lorem, getline(1, '$')) + bw! + bw! + bw! +endfunc + " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/textformat.c b/src/textformat.c index 41ec2cfe4b..d380899c8f 100644 --- a/src/textformat.c +++ b/src/textformat.c @@ -59,9 +59,11 @@ internal_format( int safe_tw = trim_to_int(8 * (vimlong_T)textwidth); #ifdef FEAT_LINEBREAK int has_lbr = curwin->w_p_lbr; + int has_bri = curwin->w_p_bri; // make sure win_lbr_chartabsize() counts correctly curwin->w_p_lbr = FALSE; + curwin->w_p_bri = FALSE; #endif // When 'ai' is off we don't want a space under the cursor to be @@ -475,6 +477,7 @@ internal_format( #ifdef FEAT_LINEBREAK curwin->w_p_lbr = has_lbr; + curwin->w_p_bri = has_bri; #endif if (!format_only && haveto_redraw) { diff --git a/src/version.c b/src/version.c index cac24ffb5a..71e56a223f 100644 --- a/src/version.c +++ b/src/version.c @@ -705,6 +705,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 377, +/**/ 376, /**/ 375, |