чување ef9e7169a5e49c44d590f1014add89112846e33e
родитељ cf5f9b67a30d72e59779b74d83777421d506cfa7
Аутор: Страхиња Радић <sr@strahinja.org>
Датум: Tue, 30 Dec 2025 16:06:12 +0100
Bugfix: backspacing text erased beginning of previous line
Diffstat:
измењених датотека: 3, додавања: 6(+), брисања: 5(-)
diff --git a/TODO b/TODO
@@ -9,9 +9,6 @@ TODO
then a save is attempted. Bail out (current behavior)?
- What if a file was on a USB flash which was pulled out?
-[ ] Investigate: typing text (at the end of a line) sometimes erases
- text at the end of one of the previous lines in the same paragraph?!
-
[ ] Investigate: pressing C-S on work laptop (possibly in the case when editing
a symlink)
diff --git a/TODO.done b/TODO.done
@@ -1,6 +1,10 @@
Done or canceled todos
======================
+[x] Investigate: typing text (at the end of a line) sometimes erases
+ text at the end of one of the previous lines in the same paragraph?!
+ - Fixed; this pretty nasty bug was due to improper use of bounds
+
[x] Syntax patch: remove unused variables
[x] Bugfix: SEGV in format_codep when rereading the file
diff --git a/sled.c b/sled.c
@@ -352,11 +352,11 @@ erase_backwards(struct DrawState* state)
if (state->coord.col > 0)
{
ssize_t i = state->coord.col;
- do
+ while (i <= buffer_line->length)
{
buffer_line->text[i - 1] = buffer_line->text[i];
i++;
- } while (buffer_line->text[i]);
+ }
buffer_line->text[i - 1] = 0;
buffer_line->length--;
position_to(state, state->coord.row, state->coord.col - 1);