Made it open the example file if the last opened file doesn't exist anymore.

This commit is contained in:
The Wobbler 2024-11-30 22:16:00 +01:00
parent eb9c22967f
commit b829164f0d

View file

@ -110,6 +110,11 @@ class Utils:
if len(sys.argv) == 1: # if no parameters were passed to the editor if len(sys.argv) == 1: # if no parameters were passed to the editor
file_path = self.app.settings.last_opened_file 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]) file = File(self.app, file_path, file_path.split("/")[-1])
self.app.open_files[file_path] = file self.app.open_files[file_path] = file