diff --git a/mutmut/__main__.py b/mutmut/__main__.py index 9884cb68..4322d2b6 100644 --- a/mutmut/__main__.py +++ b/mutmut/__main__.py @@ -1461,7 +1461,9 @@ def browse(): from textual.containers import Container from textual.widgets import Footer from textual.widgets import DataTable - from textual.widgets import TextArea + from textual.widgets import Static + from textual.widget import Widget + from rich.syntax import Syntax class ResultBrowser(App): loading_id = None @@ -1488,7 +1490,8 @@ def compose(self): with Container(classes='container'): yield DataTable(id='files') yield DataTable(id='mutants') - yield TextArea(id='diff_view') + with Widget(id="diff_view_widget"): + yield Static(id='diff_view') yield Footer() def on_mount(self): @@ -1547,9 +1550,9 @@ def on_data_table_row_highlighted(self, event): assert event.data_table.id == 'mutants' diff_view = self.query_one('#diff_view') if event.row_key.value is None: - diff_view.text = '' + diff_view.update('') else: - diff_view.text = '' + diff_view.update('') self.loading_id = event.row_key.value def load_thread(): @@ -1557,9 +1560,9 @@ def load_thread(): try: d = get_diff_for_mutant(event.row_key.value) if event.row_key.value == self.loading_id: - diff_view.text = d + diff_view.update(Syntax(d, "diff")) except Exception as e: - diff_view.text = f'<{type(e)} {e}>' + diff_view.update(f"<{type(e)} {e}>") t = Thread(target=load_thread) t.start() diff --git a/mutmut/result_browser_layout.tcss b/mutmut/result_browser_layout.tcss index b40dda59..d3672f88 100644 --- a/mutmut/result_browser_layout.tcss +++ b/mutmut/result_browser_layout.tcss @@ -24,3 +24,12 @@ DataTable:focus .datatable--cursor { color: black; background: orange; } + +#diff_view_widget{ + height: 50%; + border: solid; + overflow-y: scroll; +} + +#diff_view{ +}