Skip to content

Commit 3b93cf2

Browse files
committed
patch 9.0.0458: splitting a line with a text prop "above" moves it down
Problem: Splitting a line with a text prop "above" moves it to a new line below. Solution: Keep an "above" text prop above the first line.
1 parent a04f457 commit 3b93cf2

File tree

4 files changed

+23
-5
lines changed

4 files changed

+23
-5
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
| +0#0000e05#a8a8a8255@1| +0#af5f00255#ffffff0@1|1| |f+0#0000000#ffff4012|i|r|s|t| |t|h|i|n|g| |a|b|o|v|e| @36
2+
| +0#0000e05#a8a8a8255@1| +0#af5f00255#ffffff0@3|s+0#0000000#ffd7ff255|e|c|o|n|d| |t|h|i|n|g| |a|b|o|v|e| @35
3+
| +0#0000e05#a8a8a8255@1| +0#af5f00255#ffffff0@3|i+0#0000000&|n|s|e|r|t|e|d| @45
4+
| +0#0000e05#a8a8a8255@1| +0#af5f00255#ffffff0@1|2| >o+0#0000000&|n|e| |t|w|o| @46
5+
| +0#0000e05#a8a8a8255@1| +0#af5f00255#ffffff0@3|b+0#0000000#5fd7ff255|e|l|o|w| +0&#ffffff0@48
6+
| +0#0000e05#a8a8a8255@1| +0#af5f00255#ffffff0@1|3| |t+0#0000000&|h|r|e@1| |f|o|u|r| @43
7+
| +0#0000e05#a8a8a8255@1| +0#af5f00255#ffffff0@1|4| | +0#0000000&@2|a+0&#ffff4012|n|o|t|h|e|r| |t|h|i|n|g| @37
8+
| +0#0000e05#a8a8a8255@1| +0#af5f00255#ffffff0@3|f+0#0000000&|i|v|e| |s|i|x| @45
9+
@42|2|,|1| @10|A|l@1|

src/testdir/test_textprop.vim

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2886,6 +2886,9 @@ func Test_props_with_text_above()
28862886
call term_sendkeys(buf, "V")
28872887
call VerifyScreenDump(buf, 'Test_prop_with_text_above_7', {})
28882888

2889+
call term_sendkeys(buf, "\<Esc>ls\<CR>\<Esc>")
2890+
call VerifyScreenDump(buf, 'Test_prop_with_text_above_8', {})
2891+
28892892
call StopVimInTerminal(buf)
28902893
endfunc
28912894

src/textprop.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2264,16 +2264,21 @@ adjust_props_for_split(
22642264
proptype_T *pt;
22652265
int start_incl, end_incl;
22662266
int cont_prev, cont_next;
2267+
int prop_col;
22672268

22682269
// copy the prop to an aligned structure
22692270
mch_memmove(&prop, props + i * sizeof(textprop_T), sizeof(textprop_T));
22702271

22712272
pt = text_prop_type_by_id(curbuf, prop.tp_type);
22722273
start_incl = (pt != NULL && (pt->pt_flags & PT_FLAG_INS_START_INCL));
22732274
end_incl = (pt != NULL && (pt->pt_flags & PT_FLAG_INS_END_INCL));
2274-
cont_prev = prop.tp_col != MAXCOL && prop.tp_col + !start_incl <= kept;
2275-
cont_next = prop.tp_col != MAXCOL
2276-
&& skipped <= prop.tp_col + prop.tp_len - !end_incl;
2275+
2276+
// a text prop "above" behaves like it is on the first text column
2277+
prop_col = (prop.tp_flags & TP_FLAG_ALIGN_ABOVE) ? 1 : prop.tp_col;
2278+
2279+
cont_prev = prop_col != MAXCOL && prop_col + !start_incl <= kept;
2280+
cont_next = prop_col != MAXCOL
2281+
&& skipped <= prop_col + prop.tp_len - !end_incl;
22772282
// when a prop has text it is never copied
22782283
if (prop.tp_id < 0 && cont_next)
22792284
cont_prev = FALSE;
@@ -2292,8 +2297,7 @@ adjust_props_for_split(
22922297

22932298
// Only add the property to the next line if the length is bigger than
22942299
// zero.
2295-
if ((cont_next || prop.tp_col == MAXCOL)
2296-
&& ga_grow(&nextprop, 1) == OK)
2300+
if ((cont_next || prop_col == MAXCOL) && ga_grow(&nextprop, 1) == OK)
22972301
{
22982302
textprop_T *p = ((textprop_T *)nextprop.ga_data) + nextprop.ga_len;
22992303

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -703,6 +703,8 @@ static char *(features[]) =
703703

704704
static int included_patches[] =
705705
{ /* Add new patch number below this line */
706+
/**/
707+
458,
706708
/**/
707709
457,
708710
/**/

0 commit comments

Comments
 (0)