@@ -957,13 +957,17 @@ clear_buf_prop_types(buf_T *buf)
957957 * shift by "bytes_added" (can be negative).
958958 * Note that "col" is zero-based, while tp_col is one-based.
959959 * Only for the current buffer.
960+ * When "save_for_undo" is TRUE then call u_savesub() before making changes to
961+ * the line.
960962 * Caller is expected to check b_has_textprop and "bytes_added" being non-zero.
963+ * Returns TRUE when props were changed.
961964 */
962- void
965+ int
963966adjust_prop_columns (
964967 linenr_T lnum ,
965968 colnr_T col ,
966- int bytes_added )
969+ int bytes_added ,
970+ int save_for_undo )
967971{
968972 int proplen ;
969973 char_u * props ;
@@ -974,11 +978,11 @@ adjust_prop_columns(
974978 size_t textlen ;
975979
976980 if (text_prop_frozen > 0 )
977- return ;
981+ return FALSE ;
978982
979983 proplen = get_text_props (curbuf , lnum , & props , TRUE);
980984 if (proplen == 0 )
981- return ;
985+ return FALSE ;
982986 textlen = curbuf -> b_ml .ml_line_len - proplen * sizeof (textprop_T );
983987
984988 wi = 0 ; // write index
@@ -1001,6 +1005,9 @@ adjust_prop_columns(
10011005 }
10021006 else
10031007 tmp_prop .tp_col += bytes_added ;
1008+ // Save for undo if requested and not done yet.
1009+ if (save_for_undo && !dirty )
1010+ u_savesub (lnum );
10041011 dirty = TRUE;
10051012 if (tmp_prop .tp_len <= 0 )
10061013 continue ; // drop this text property
@@ -1016,6 +1023,9 @@ adjust_prop_columns(
10161023 tmp_prop .tp_len += bytes_added + after ;
10171024 else
10181025 tmp_prop .tp_len += bytes_added ;
1026+ // Save for undo if requested and not done yet.
1027+ if (save_for_undo && !dirty )
1028+ u_savesub (lnum );
10191029 dirty = TRUE;
10201030 if (tmp_prop .tp_len <= 0 )
10211031 continue ; // drop this text property
@@ -1034,6 +1044,7 @@ adjust_prop_columns(
10341044 curbuf -> b_ml .ml_flags |= ML_LINE_DIRTY ;
10351045 curbuf -> b_ml .ml_line_len = newlen ;
10361046 }
1047+ return dirty ;
10371048}
10381049
10391050/*
0 commit comments