From 7048c36ba8d1562b5fb56a1ed176e16ee24f3a29 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Mon, 11 Aug 2025 00:57:01 -0400 Subject: [PATCH] vim-patch:8.2.0115: byte2line() does not work correctly with text properties Problem: Byte2line() does not work correctly with text properties. (Billie Cleek) Solution: Take the bytes of the text properties into account. (closes vim/vim#5334) https://github.com/vim/vim/commit/9df53b62de86f544b41bef5e964b7fc8ae5231e3 Co-authored-by: Bram Moolenaar --- src/nvim/memline.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/nvim/memline.c b/src/nvim/memline.c index 14996768f2..47cc6522e3 100644 --- a/src/nvim/memline.c +++ b/src/nvim/memline.c @@ -4023,9 +4023,12 @@ int ml_find_line_or_offset(buf_T *buf, linenr_T lnum, int *offp, bool no_ff) } } else { extra = 0; - while (offset >= size - + text_end - (int)((dp->db_index[idx]) & DB_INDEX_MASK) - + ffdos) { + while (true) { + if (!(offset >= size + + text_end - (int)((dp->db_index[idx]) & DB_INDEX_MASK) + + ffdos)) { + break; + } if (ffdos) { size++; }