From c5a3c1bfdd8fe0fe81a8094ab68b7a95bdb4ea39 Mon Sep 17 00:00:00 2001 From: Leo Tenenbaum Date: Sat, 26 Dec 2020 12:15:22 -0500 Subject: fixed buffer_pos_diff problem; undo seems to be fully working now? --- buffer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buffer.c b/buffer.c index 6721669..e903379 100644 --- a/buffer.c +++ b/buffer.c @@ -243,7 +243,7 @@ static i64 buffer_pos_diff(TextBuffer *buffer, BufferPos p1, BufferPos p2) { i64 chars_in_lines_in_between = 0; // now we need to add up the lengths of the lines between p1 and p2 for (Line *line = buffer->lines + (p1.line + 1), *end = buffer->lines + p2.line; line != end; ++line) { - chars_in_lines_in_between += line->len; + chars_in_lines_in_between += line->len + 1; // +1 for newline } i64 total = chars_at_end_of_p1_line + chars_in_lines_in_between + chars_at_start_of_p2_line; return total * factor; -- cgit v1.2.3