From b829164f0dae421978a8beaea2ee36c6fa03d8c3 Mon Sep 17 00:00:00 2001 From: EKNr1 Date: Sat, 30 Nov 2024 22:16:00 +0100 Subject: [PATCH] Made it open the example file if the last opened file doesn't exist anymore. --- utils.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/utils.py b/utils.py index ec78e85..f7bc25e 100644 --- a/utils.py +++ b/utils.py @@ -110,6 +110,11 @@ class Utils: if len(sys.argv) == 1: # if no parameters were passed to the editor file_path = self.app.settings.last_opened_file - if os.path.isfile(file_path): + if os.path.isfile(file_path): # open last opened file if it still exists else open the example file + file = File(self.app, file_path, file_path.split("/")[-1]) + self.app.open_files[file_path] = file + + else: + file_path = f"{os.path.dirname(os.path.abspath(__file__))}/example.txt" file = File(self.app, file_path, file_path.split("/")[-1]) self.app.open_files[file_path] = file