From 43450a8c37203113a51d1dfa2aa640b5d6beb500 Mon Sep 17 00:00:00 2001 From: Joseph Ferano Date: Thu, 2 Nov 2023 18:23:07 +0700 Subject: [PATCH] Fix bug on K_DELETE when the line is empty --- fide.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/fide.py b/fide.py index 9119ba0..70c2b56 100755 --- a/fide.py +++ b/fide.py @@ -106,14 +106,15 @@ if __name__ == '__main__': if cursor.col >= rows[cursor.row].length: if cursor.row < len(rows) - 1: below_row = rows.pop(cursor.row+1) - row = rows[cursor.row] - row.text.insert(below_row.text.get_text(), row.length) + if below_row.length > 0: + row.text.insert(below_row.text.get_text(), row.length) + row.length += below_row.length cursor.want_col = cursor.col - row.length += below_row.length else: - row.text.delete(cursor.col, 1) - row.length -= 1 - cursor.want_col = cursor.col + if row.length >= 1: + row.text.delete(cursor.col, 1) + row.length -= 1 + cursor.want_col = cursor.col elif event.key == pg.K_LEFT: if cursor.col == 0: if cursor.row > 0: