Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libs/code/deepagents_code/tui/widgets/diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def _compose_diff_content(
yield Static(
Content.assemble(
(f"{glyphs.box_vertical}{old_num:>{width}}", "dim"),
f" {content}",
f" {content}",
),
)
old_num += 1
Expand Down
10 changes: 10 additions & 0 deletions libs/code/tests/unit_tests/tui/widgets/test_diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,16 @@ def test_added_and_removed_rows_get_css_classes(self) -> None:
assert "diff-line-removed" in removed
assert context == set()

def test_content_columns_align_across_line_types(self) -> None:
"""Context/added/removed rows start their content at the same column."""
texts = _texts(_rendered(_SAMPLE_DIFF))
ctx = next(t for t in texts if "ctx" in t)
removed = next(t for t in texts if "removed" in t)
added1 = next(t for t in texts if "added1" in t)
# The gutter glyph, right-aligned line number, and separator must be
# the same width on every row so the diff body lines up vertically.
assert ctx.index("ctx") == removed.index("removed") == added1.index("added1")

def test_max_lines_truncates_with_marker(self) -> None:
"""Beyond `max_lines`, a truncation marker replaces remaining rows."""
diff = "\n".join(["@@ -1,5 +1,5 @@", *(f"+line{i}" for i in range(5))])
Expand Down
Loading