diff --git a/borgmatic/actions/browse/file_preview.py b/borgmatic/actions/browse/file_preview.py index 88b403d6..7e117eae 100644 --- a/borgmatic/actions/browse/file_preview.py +++ b/borgmatic/actions/browse/file_preview.py @@ -75,19 +75,14 @@ class File_preview(textual.widgets.RichLog): ) def on_file_preview_loaded(self, file_contents): - import time - - logger.debug(('on_file_preview_loaded', time.time())) self.loading_timer.stop() self.clear() if file_contents is None: self.write('Cannot display a preview for this file') else: - logger.debug(('before write', time.time())) + # Only pass the file path and not its contents to guess_lexer(). Passing the contents is + # more accurate, but also much slower. self.write( - rich.syntax.Syntax( - file_contents, rich.syntax.Syntax.guess_lexer(self.file_path, file_contents) - ) + rich.syntax.Syntax(file_contents, rich.syntax.Syntax.guess_lexer(self.file_path)) ) - logger.debug(('after write', time.time())) diff --git a/borgmatic/actions/browse/workers.py b/borgmatic/actions/browse/workers.py index d84bf187..bf80cf4c 100644 --- a/borgmatic/actions/browse/workers.py +++ b/borgmatic/actions/browse/workers.py @@ -171,9 +171,6 @@ def load_file_preview( repository dict, an archive name, the path of a file in that archive, and a loading indicator timer, load the contents of the file and write it into the given file preview widget. ''' - import time - - logger.debug(('before get_archive_file_content', time.time())) file_contents = borgmatic.actions.browse.archive.get_archive_file_content( config, repository, archive_name, file_path ) diff --git a/tests/integration/actions/browse/test_directory_list.py b/tests/integration/actions/browse/test_directory_list.py index 99dd358b..5b72b5af 100644 --- a/tests/integration/actions/browse/test_directory_list.py +++ b/tests/integration/actions/browse/test_directory_list.py @@ -122,7 +122,9 @@ def test_add_archive_paths_retains_loading_indicator_at_bottom(): def test_directory_list_with_root_directory_adds_loading_indicator(): - flexmock(module.borgmatic.actions.browse.loading).should_receive('add_inline_loading_indicator').once() + flexmock(module.borgmatic.actions.browse.loading).should_receive( + 'add_inline_loading_indicator' + ).once() directory_list = module.Directory_list( config=flexmock(), repository=flexmock(), archive_name='archive'