diff --git a/lib/tfw/components/source_code_event_handler.py b/lib/tfw/components/source_code_event_handler.py index b4f474f..993d744 100644 --- a/lib/tfw/components/source_code_event_handler.py +++ b/lib/tfw/components/source_code_event_handler.py @@ -90,8 +90,15 @@ class SourceCodeEventHandler(TriggerlessEventHandler): return data def select_dir(self, data): - try: self.filemanager.workdir = data['directory'] - except EnvironmentError: log.exception('Failed to select directory "{}"'.format(data['directory'])) + try: + self.filemanager.workdir = data['directory'] + try: + self.filemanager.select_file(self.filemanager.files[0]) + data['content'] = self.filemanager.file_contents + except IndexError: + data['content'] = 'No files in this directory :(' + except EnvironmentError: + log.exception('Failed to select directory "{}"'.format(data['directory'])) return data def attach_fileinfo(self, data):