summaryrefslogtreecommitdiff
path: root/buffer.c
diff options
context:
space:
mode:
authorLeo Tenenbaum <pommicket@gmail.com>2020-12-26 12:15:22 -0500
committerLeo Tenenbaum <pommicket@gmail.com>2020-12-26 12:15:22 -0500
commitc5a3c1bfdd8fe0fe81a8094ab68b7a95bdb4ea39 (patch)
treedcf5aa3bf5478b73913fbd4554b36427fdba8317 /buffer.c
parent993286be407ebffb50e15cb53e28c11cfbf47dcb (diff)
fixed buffer_pos_diff problem; undo seems to be fully working now?
Diffstat (limited to 'buffer.c')
-rw-r--r--buffer.c2
1 files changed, 1 insertions, 1 deletions
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;