From 7ac1145fbebb66dfee325dc5265309877d941c4e Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 6 Mar 2024 20:54:22 +0100 Subject: patch 9.1.0153: Text properties corrupted with fo+=aw and backspace Problem: Text properties corrupted with fo+=aw and backspace Solution: Allocate line and move text properties (zeertzjq) closes: #14147 Signed-off-by: zeertzjq Signed-off-by: Christian Brabandt --- src/edit.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) (limited to 'src/edit.c') diff --git a/src/edit.c b/src/edit.c index d7c80ffcdf..998647cd8e 100644 --- a/src/edit.c +++ b/src/edit.c @@ -4101,12 +4101,30 @@ ins_bs( && has_format_option(FO_WHITE_PAR)) { char_u *ptr = ml_get_buf(curbuf, curwin->w_cursor.lnum, - TRUE); - int len; + FALSE); + int len = ml_get_curline_len(); - len = (int)STRLEN(ptr); if (len > 0 && ptr[len - 1] == ' ') - ptr[len - 1] = NUL; + { + char_u *newp = alloc(curbuf->b_ml.ml_line_len - 1); + + if (newp != NULL) + { + mch_memmove(newp, ptr, len - 1); + newp[len - 1] = NUL; + if (curbuf->b_ml.ml_line_len > len + 1) + mch_memmove(newp + len, ptr + len + 1, + curbuf->b_ml.ml_line_len - len - 1); + + if (curbuf->b_ml.ml_flags + & (ML_LINE_DIRTY | ML_ALLOCATED)) + vim_free(curbuf->b_ml.ml_line_ptr); + curbuf->b_ml.ml_line_ptr = newp; + curbuf->b_ml.ml_line_len--; + curbuf->b_ml.ml_line_textlen--; + curbuf->b_ml.ml_flags |= ML_LINE_DIRTY; + } + } } (void)do_join(2, FALSE, FALSE, FALSE, FALSE); -- cgit v1.2.3