if a file is given on the command line, then open only this file

This commit is contained in:
2023-01-30 19:28:27 +01:00
parent 82c74e48b5
commit 3c0cb97703
2 changed files with 8 additions and 6 deletions

View File

@@ -85,9 +85,7 @@ if __name__ == "__main__":
window = PluginRegistry.execute_single("create_main_window") window = PluginRegistry.execute_single("create_main_window")
window.show() window.show()
PluginRegistry.execute("after_start") PluginRegistry.execute("after_start", cmd_args.files)
for file in cmd_args.files:
PluginRegistry.execute("open_file", file)
register_signal_handler() register_signal_handler()

View File

@@ -85,9 +85,13 @@ class OpenFilePlugin(PluginBase):
def after_open_file(self, file: str): def after_open_file(self, file: str):
self._remember_recent_file(file) self._remember_recent_file(file)
def after_start(self): def after_start(self, files_from_command_line: [str]):
open_files_as_string = self.settings.get_session('general', 'open_files', fallback='')
files = open_files_as_string.split(os.pathsep) if files_from_command_line:
files = files_from_command_line
else:
open_files_as_string = self.settings.get_session('general', 'open_files', fallback='')
files = open_files_as_string.split(os.pathsep)
if "" in files: if "" in files:
files.remove("") files.remove("")
for file in files: for file in files: