diff: Add diff hunk gutter
0e4a04d99ae02376c4ead8af8d7eb4273193242c
1 parent
66aeffd9
crates/brain/src/decorate.rs
+6 -9
| 2 | 2 | //! |
|
| 3 | 3 | //! The diff viewer is review-agnostic; this decorator feeds it per-hunk |
|
| 4 | 4 | //! markers. A [`Decorations`] value is an immutable snapshot of the review |
|
| 5 | 5 | //! state, rebuilt and reinstalled by the session whenever acceptance or |
|
| 6 | 6 | //! comments change, so the viewer never observes state mutating underneath |
|
| 7 | - | //! it. Accepted hunks are dimmed and marked with a check mark; commented |
|
| 7 | + | //! it. Accepted hunks are dimmed and marked by a green gutter; commented |
|
| 8 | 8 | //! hunks show a comment marker and count; hunks that need review after a |
|
| 9 | 9 | //! rebase show a rebase marker. |
|
| 10 | 10 | ||
| 11 | 11 | use std::collections::{BTreeMap, BTreeSet}; |
|
| 12 | 12 |
| 20 | 20 | use crate::comments::Comments; |
|
| 21 | 21 | use crate::review::Review; |
|
| 22 | 22 | ||
| 23 | 23 | /// Check mark drawn beside accepted hunks and fully accepted files: โ. |
|
| 24 | 24 | const ACCEPTED_MARK: char = 'โ'; |
|
| 25 | - | /// Marker drawn in the corner of a hunk that has comments: ๐ฉ. |
|
| 25 | + | /// Vertical rule drawn in the gutter beside accepted hunks: โ. |
|
| 26 | + | const ACCEPTED_GUTTER: char = 'โ'; |
|
| 27 | + | /// Marker drawn beside a hunk that has comments: ๐ฉ. |
|
| 26 | 28 | const COMMENT_MARK: char = '๐ฉ'; |
|
| 27 | 29 | /// Marker drawn beside a hunk that was pending after a review rebase. |
|
| 28 | 30 | const REBASE_PENDING_MARK: char = 'โป'; |
|
| 29 | 31 | ||
| 30 | 32 | /// Immutable decoration snapshot of one commit's review state. |
| 113 | 115 | if !accepted && !rebase_pending && comments == 0 { |
|
| 114 | 116 | return HunkDecoration::default(); |
|
| 115 | 117 | } |
|
| 116 | 118 | ||
| 117 | 119 | let mut corner = Line::blank(); |
|
| 118 | - | if accepted { |
|
| 119 | - | corner = corner.item(Label::from_char(ACCEPTED_MARK).fg(self.palette.positive_fg)); |
|
| 120 | - | } |
|
| 121 | 120 | if rebase_pending { |
|
| 122 | - | if accepted { |
|
| 123 | - | corner = corner.item(Label::space()); |
|
| 124 | - | } |
|
| 125 | 121 | corner = corner.item(Label::from_char(REBASE_PENDING_MARK).fg(colors::rgb::ORANGE)); |
|
| 126 | 122 | } |
|
| 127 | 123 | if comments > 0 { |
|
| 128 | - | if accepted || rebase_pending { |
|
| 124 | + | if rebase_pending { |
|
| 129 | 125 | corner = corner.item(Label::space()); |
|
| 130 | 126 | } |
|
| 131 | 127 | corner = |
|
| 132 | 128 | corner.item(Label::new(&format!("{comments} {COMMENT_MARK}")).fg(colors::rgb::DIM)); |
|
| 133 | 129 | } |
|
| 134 | 130 | ||
| 135 | 131 | HunkDecoration { |
|
| 132 | + | gutter: accepted.then(|| Paint::new(ACCEPTED_GUTTER).fg(self.palette.positive_fg)), |
|
| 136 | 133 | corner, |
|
| 137 | 134 | style: accepted.then(|| Style::default().dim()), |
|
| 138 | 135 | } |
|
| 139 | 136 | } |
|
| 140 | 137 | } |
crates/brain/src/session.rs
+4 -2
| 424 | 424 | self.reject_hunks(BTreeSet::from([(self.current, hunk)]))?; |
|
| 425 | 425 | } else { |
|
| 426 | 426 | self.brain.apply_patches([patch.as_str()])?; |
|
| 427 | 427 | } |
|
| 428 | 428 | self.reconcile_reviews()?; |
|
| 429 | - | if !accepted { |
|
| 429 | + | if !accepted && !self.visibility.show_accepted { |
|
| 430 | 430 | self.current()?.viewer.apply(DiffAction::NextHunk, area); |
|
| 431 | 431 | } |
|
| 432 | 432 | ||
| 433 | 433 | Ok(()) |
|
| 434 | 434 | } |
| 829 | 829 | if let Some(loaded) = &mut slot.loaded { |
|
| 830 | 830 | loaded.review.replace(reconciled.accepted); |
|
| 831 | 831 | loaded.refresh_decorations(); |
|
| 832 | 832 | } |
|
| 833 | 833 | } |
|
| 834 | - | self.refresh_visibility()?; |
|
| 834 | + | if !self.visibility.show_accepted { |
|
| 835 | + | self.refresh_visibility()?; |
|
| 836 | + | } |
|
| 835 | 837 | Ok(()) |
|
| 836 | 838 | } |
|
| 837 | 839 | ||
| 838 | 840 | /// Draws a frame, requesting highlights for visible rows before it and |
|
| 839 | 841 | /// lookahead rows after it. |
crates/diff/src/decorate.rs
+5 -4
| 104 | 104 | } |
|
| 105 | 105 | } |
|
| 106 | 106 | ||
| 107 | 107 | /// Decoration overlaid on a hunk. |
|
| 108 | 108 | /// |
|
| 109 | - | /// Decorations never add rows: the corner is drawn over the hunk's first body |
|
| 110 | - | /// row, and the style is composed onto the hunk's existing body rows. |
|
| 109 | + | /// Decorations never add rows: the gutter and corner are drawn into existing |
|
| 110 | + | /// body rows, and the style is composed onto those rows. |
|
| 111 | 111 | #[derive(Clone, Debug, Default)] |
|
| 112 | 112 | pub struct HunkDecoration { |
|
| 113 | - | /// Markers drawn in the hunk's top-right corner, for example an approval |
|
| 114 | - | /// marker and a comment-count indicator. |
|
| 113 | + | /// Optional marker drawn in the gutter beside every hunk body row. |
|
| 114 | + | pub gutter: Option<Paint<char>>, |
|
| 115 | + | /// Markers drawn in the hunk's top-right corner. |
|
| 115 | 116 | pub corner: Line, |
|
| 116 | 117 | /// Style composed onto the hunk's body rows, used to mute approved or |
|
| 117 | 118 | /// otherwise inactive hunks. |
|
| 118 | 119 | pub style: Option<Style>, |
|
| 119 | 120 | } |
crates/diff/src/viewer.rs
+51 -25
| 11 | 11 | ||
| 12 | 12 | use rustik_highlight as syntax; |
|
| 13 | 13 | use rustik_tui as tui; |
|
| 14 | 14 | use tui::{ |
|
| 15 | 15 | Badge, Buffer, Cell, Color, Constraint, Control, Event, HStack, Key, Label, Line, Mouse, |
|
| 16 | - | MouseButton, Rect, Scroll, ScrollView, ScrollbarStyle, Size, Style, Table, TableOptions, Text, |
|
| 17 | - | VStack, View, Viewport, Widget, colors, |
|
| 16 | + | MouseButton, Paint, Rect, Scroll, ScrollView, ScrollbarStyle, Size, Style, Table, TableOptions, |
|
| 17 | + | Text, VStack, View, Viewport, Widget, colors, |
|
| 18 | 18 | }; |
|
| 19 | 19 | ||
| 20 | 20 | use crate::context::{self, ContextChange, ContextState}; |
|
| 21 | 21 | use crate::decorate::{DiffDecorator, FileDecoration, HunkDecoration, ReviewProgress}; |
|
| 22 | 22 | use crate::highlight::{DiffHighlighter, HighlightKeyInput, HighlightResult}; |
| 41 | 41 | ||
| 42 | 42 | /// Minimum width before the viewer attempts table-style diff rows. |
|
| 43 | 43 | const MIN_RENDER_COLS: usize = 12; |
|
| 44 | 44 | /// Width of old and new line number cells. |
|
| 45 | 45 | const LINE_NUMBER_WIDTH: usize = 5; |
|
| 46 | + | /// Width of the review-state gutter before the line numbers. |
|
| 47 | + | const REVIEW_GUTTER_WIDTH: usize = 1; |
|
| 46 | 48 | /// Foreground color used by old and new line number cells. |
|
| 47 | 49 | const LINE_NUMBER_FG: Color = colors::fixed::DIM; |
|
| 48 | 50 | /// Foreground color used by line number cells in the focused hunk. |
|
| 49 | 51 | const SELECTED_LINE_NUMBER_FG: Color = Color::Fixed(242); |
|
| 50 | 52 | /// Width of the hunk marker cell. |
| 319 | 321 | line: Line, |
|
| 320 | 322 | /// Source-row metadata when this is a diff source row. |
|
| 321 | 323 | diff: Option<DiffLineMeta>, |
|
| 322 | 324 | } |
|
| 323 | 325 | ||
| 326 | + | /// Hunk decoration resolved for one rendered body row. |
|
| 327 | + | #[derive(Clone, Copy, Debug, Default)] |
|
| 328 | + | struct HunkRowDecoration { |
|
| 329 | + | /// Optional marker drawn before a changed row. |
|
| 330 | + | gutter: Option<Paint<char>>, |
|
| 331 | + | /// Style composed onto the row body. |
|
| 332 | + | style: Option<Style>, |
|
| 333 | + | } |
|
| 334 | + | ||
| 324 | 335 | /// Render location of a row inside one file card. |
|
| 325 | 336 | #[derive(Clone, Copy, Debug, Eq, PartialEq)] |
|
| 326 | 337 | struct FileRowLocation<'a> { |
|
| 327 | 338 | /// File containing the row. |
|
| 328 | 339 | file: &'a FileDiff, |
| 1364 | 1375 | Line::pad(&mut line, child_cols); |
|
| 1365 | 1376 | Line::new(border.left(1)).extend(line).item(border.right(1)) |
|
| 1366 | 1377 | }; |
|
| 1367 | 1378 | // Dedicated hunk-gap marker row keeps spacing between non-adjacent hunks. |
|
| 1368 | 1379 | let hunk_gap_line = Line::blank() |
|
| 1380 | + | .extend(Line::blank().padded(REVIEW_GUTTER_WIDTH)) |
|
| 1369 | 1381 | .extend(Line::blank().padded(LINE_NUMBER_WIDTH)) |
|
| 1370 | 1382 | .extend(Line::blank().padded(LINE_NUMBER_WIDTH)) |
|
| 1371 | 1383 | .extend(Self::marker_cell(HUNK_GAP_MARKER_CELL, colors::rgb::DIM)); |
|
| 1372 | 1384 | ||
| 1373 | 1385 | match local { |
| 1422 | 1434 | line: wrap_child(hunk_gap_line), |
|
| 1423 | 1435 | diff: None, |
|
| 1424 | 1436 | }; |
|
| 1425 | 1437 | } |
|
| 1426 | 1438 | if local < body_end { |
|
| 1427 | - | let mut row = self.hunk_row_at(file, hunk, local - body_start, child_cols); |
|
| 1428 | 1439 | let decoration = self.hunk_decoration(file.id, hunk.id); |
|
| 1429 | - | if let Some(style) = decoration.style { |
|
| 1430 | - | row.line = row.line.style(style); |
|
| 1431 | - | } |
|
| 1440 | + | let mut row = |
|
| 1441 | + | self.hunk_row_at(file, hunk, local - body_start, child_cols, &decoration); |
|
| 1432 | 1442 | // The corner marker is drawn over the hunk's first body row. |
|
| 1433 | 1443 | if local == body_start { |
|
| 1434 | 1444 | row.line = Self::overlay_corner(row.line, &decoration.corner, child_cols); |
|
| 1435 | 1445 | } |
|
| 1436 | 1446 | let expanded = row |
| 1767 | 1777 | &self, |
|
| 1768 | 1778 | file: &FileDiff, |
|
| 1769 | 1779 | hunk: &crate::Hunk, |
|
| 1770 | 1780 | line_index: usize, |
|
| 1771 | 1781 | inner: usize, |
|
| 1782 | + | decoration: &HunkDecoration, |
|
| 1772 | 1783 | ) -> RenderRow { |
|
| 1773 | 1784 | let (old_line, new_line) = Self::hunk_line_numbers(hunk, line_index); |
|
| 1774 | 1785 | let line = &hunk.lines[line_index]; |
|
| 1775 | 1786 | let meta = DiffLineMeta::new(file, hunk.id, line, old_line, new_line); |
|
| 1776 | 1787 | ||
| 1777 | - | self.hunk_row(meta, line, old_line, inner) |
|
| 1788 | + | self.hunk_row(meta, line, old_line, inner, decoration) |
|
| 1778 | 1789 | } |
|
| 1779 | 1790 | ||
| 1780 | 1791 | /// Returns source metadata for one rendered hunk body row. |
|
| 1781 | 1792 | fn hunk_meta_at(&self, file: &FileDiff, hunk: &crate::Hunk, line_index: usize) -> DiffLineMeta { |
|
| 1782 | 1793 | let (old_line, new_line) = Self::hunk_line_numbers(hunk, line_index); |
| 1799 | 1810 | &self, |
|
| 1800 | 1811 | meta: DiffLineMeta, |
|
| 1801 | 1812 | line: &DiffLine, |
|
| 1802 | 1813 | old_line: u32, |
|
| 1803 | 1814 | row_cols: usize, |
|
| 1815 | + | decoration: &HunkDecoration, |
|
| 1804 | 1816 | ) -> RenderRow { |
|
| 1805 | 1817 | let line_number_fg = if matches!(self.state.focus, Some(DiffFocus::Hunk(focused)) if focused == meta.hunk) |
|
| 1806 | 1818 | { |
|
| 1807 | 1819 | SELECTED_LINE_NUMBER_FG |
|
| 1808 | 1820 | } else { |
| 1858 | 1870 | Line::new(NO_NEWLINE_MARKER).style(Style::default().fg(colors::rgb::DIM)), |
|
| 1859 | 1871 | Style::default(), |
|
| 1860 | 1872 | Style::default(), |
|
| 1861 | 1873 | ), |
|
| 1862 | 1874 | }; |
|
| 1863 | - | let rendered = self.hunk_line(cells, source, row_cols, row_style, source_style); |
|
| 1875 | + | let decoration = HunkRowDecoration { |
|
| 1876 | + | gutter: if matches!(line.kind, DiffLineKind::Addition | DiffLineKind::Deletion) { |
|
| 1877 | + | decoration.gutter |
|
| 1878 | + | } else { |
|
| 1879 | + | None |
|
| 1880 | + | }, |
|
| 1881 | + | style: if matches!(self.state.focus, Some(DiffFocus::Hunk(hunk)) if hunk == meta.hunk) { |
|
| 1882 | + | None |
|
| 1883 | + | } else { |
|
| 1884 | + | decoration.style |
|
| 1885 | + | }, |
|
| 1886 | + | }; |
|
| 1887 | + | let rendered = self.hunk_line(cells, source, row_cols, row_style, source_style, decoration); |
|
| 1864 | 1888 | ||
| 1865 | 1889 | RenderRow { |
|
| 1866 | 1890 | line: rendered, |
|
| 1867 | 1891 | diff: Some(meta), |
|
| 1868 | 1892 | } |
| 1874 | 1898 | cells: [Line; 3], |
|
| 1875 | 1899 | mut source: Line, |
|
| 1876 | 1900 | row_cols: usize, |
|
| 1877 | 1901 | row_style: Style, |
|
| 1878 | 1902 | source_style: Style, |
|
| 1903 | + | decoration: HunkRowDecoration, |
|
| 1879 | 1904 | ) -> Line { |
|
| 1880 | - | let source_cols = row_cols.saturating_sub(LINE_NUMBER_WIDTH * 2 + MARKER_WIDTH); |
|
| 1905 | + | let source_cols = |
|
| 1906 | + | row_cols.saturating_sub(REVIEW_GUTTER_WIDTH + LINE_NUMBER_WIDTH * 2 + MARKER_WIDTH); |
|
| 1881 | 1907 | ||
| 1882 | 1908 | if source_cols > 0 { |
|
| 1883 | 1909 | Line::truncate(&mut source, source_cols, "โฆ"); |
|
| 1884 | 1910 | let source_width = source.width(); |
|
| 1885 | 1911 | if source_width < source_cols { |
| 1887 | 1913 | source.push(Label::new(&padding)); |
|
| 1888 | 1914 | } |
|
| 1889 | 1915 | } |
|
| 1890 | 1916 | ||
| 1891 | 1917 | let source = source.style(source_style); |
|
| 1892 | - | let mut line = Line::blank() |
|
| 1918 | + | let body_cols = row_cols.saturating_sub(REVIEW_GUTTER_WIDTH); |
|
| 1919 | + | let mut body = Line::blank() |
|
| 1893 | 1920 | .extend(cells[0].clone()) |
|
| 1894 | 1921 | .extend(cells[1].clone()) |
|
| 1895 | 1922 | .extend(cells[2].clone()) |
|
| 1896 | 1923 | .extend(source); |
|
| 1897 | 1924 | ||
| 1898 | - | Line::pad(&mut line, row_cols); |
|
| 1899 | - | Line::truncate(&mut line, row_cols, "โฆ"); |
|
| 1900 | - | line.style(row_style) |
|
| 1925 | + | Line::pad(&mut body, body_cols); |
|
| 1926 | + | Line::truncate(&mut body, body_cols, "โฆ"); |
|
| 1927 | + | body = body.style(row_style); |
|
| 1928 | + | if let Some(style) = decoration.style { |
|
| 1929 | + | body = body.style(style); |
|
| 1930 | + | } |
|
| 1931 | + | let gutter = decoration.gutter.map_or_else( |
|
| 1932 | + | || Line::blank().padded(REVIEW_GUTTER_WIDTH), |
|
| 1933 | + | |paint| Line::new(Label::from_char(paint.item).style(paint.style)), |
|
| 1934 | + | ); |
|
| 1935 | + | gutter.extend(body) |
|
| 1901 | 1936 | } |
|
| 1902 | 1937 | ||
| 1903 | 1938 | /// Returns the final source-text `Line` for a row, ready to render. |
|
| 1904 | 1939 | /// |
|
| 1905 | 1940 | /// Cached entries already include the word-diff overlay (applied once in |
| 2211 | 2246 | // its decoration override), joined by a fixed gap. |
|
| 2212 | 2247 | let mut right = decoration.annotations.clone(); |
|
| 2213 | 2248 | let stats = decoration.stats.unwrap_or(summary.stats); |
|
| 2214 | 2249 | if let Some(progress) = decoration.progress { |
|
| 2215 | 2250 | let mut progress_line = Self::progress_bar(progress, palette); |
|
| 2216 | - | progress_line.push(Label::space()); |
|
| 2217 | - | if progress.is_complete() { |
|
| 2218 | - | progress_line = progress_line.extend( |
|
| 2219 | - | Self::review_status_line(Line::new( |
|
| 2220 | - | Label::new("Approved").fg(palette.positive_fg), |
|
| 2221 | - | )) |
|
| 2222 | - | .labels() |
|
| 2223 | - | .iter() |
|
| 2224 | - | .cloned(), |
|
| 2225 | - | ); |
|
| 2226 | - | } else if let Some(stats) = |
|
| 2227 | - | Self::diffstat_line(stats.additions, stats.deletions, palette) |
|
| 2251 | + | if !progress.is_complete() |
|
| 2252 | + | && let Some(stats) = Self::diffstat_line(stats.additions, stats.deletions, palette) |
|
| 2228 | 2253 | { |
|
| 2254 | + | progress_line.push(Label::space()); |
|
| 2229 | 2255 | progress_line = |
|
| 2230 | 2256 | progress_line.extend(Self::review_status_line(stats).labels().iter().cloned()); |
|
| 2231 | 2257 | } |
|
| 2232 | 2258 | right.push(progress_line); |
|
| 2233 | 2259 | } else if let Some(stats) = Self::diffstat_line(stats.additions, stats.deletions, palette) { |
a.rs
+0 -0
a.rs
+0 -0
b.rs
+0 -0
a.rs
+0 -0
a.rs
+0 -0
a.rs
+0 -0
b.rs
+0 -0
crates/diff/tests/golden/sticky_header_before_next_file_64x5.txt
+0 -0
src/a.rs
+0 -0
src/b.rs
+0 -0
README.md
+0 -0
src/app/a.rs
+0 -0
src/lib/b.rs
+0 -0
README.md
+0 -0
a.rs
+0 -0
b.rs
+0 -0
assets/css/style.css
+0 -0
assets/css/style.css
+0 -0
first.rs
+0 -0
second.rs
+0 -0
a.rs
+0 -0
a.rs
+0 -0
a.rs
+0 -0
a.rs
+0 -0
b.rs
+0 -0
crates/diff/tests/golden.rs
+46 -3
| 1 | 1 | #![allow(clippy::unwrap_used)] |
|
| 2 | 2 | ||
| 3 | 3 | use rustik_diff::{ |
|
| 4 | - | ContextChange, Decode, DiffAction, DiffDocument, DiffFocus, DiffOptions, DiffSide, DiffViewer, |
|
| 5 | - | FileTreeMode, HighlightResult, HunkFocus, HunkId, |
|
| 4 | + | ContextChange, Decode, DiffAction, DiffDecorator, DiffDocument, DiffFocus, DiffOptions, |
|
| 5 | + | DiffSide, DiffViewer, FileDecoration, FileId, FileTreeMode, HighlightResult, HunkDecoration, |
|
| 6 | + | HunkFocus, HunkId, ReviewProgress, |
|
| 6 | 7 | }; |
|
| 7 | - | use rustik_tui::{Buffer, Color, Label, Line, Rect, Scroll, colors}; |
|
| 8 | + | use rustik_tui::{Buffer, Color, Label, Line, Paint, Rect, Scroll, Style, colors}; |
|
| 9 | + | ||
| 10 | + | /// Review decoration used to cover accepted-hunk gutters in golden frames. |
|
| 11 | + | #[derive(Clone, Debug)] |
|
| 12 | + | struct ReviewDecorator; |
|
| 13 | + | ||
| 14 | + | impl DiffDecorator for ReviewDecorator { |
|
| 15 | + | fn file(&self, _file: FileId) -> FileDecoration { |
|
| 16 | + | FileDecoration { |
|
| 17 | + | status: Some(Paint::new('โ').fg(colors::rgb::GREEN)), |
|
| 18 | + | progress: Some(ReviewProgress { |
|
| 19 | + | accepted: 2, |
|
| 20 | + | total: 2, |
|
| 21 | + | }), |
|
| 22 | + | ..FileDecoration::default() |
|
| 23 | + | } |
|
| 24 | + | } |
|
| 25 | + | ||
| 26 | + | fn hunk(&self, _file: FileId, hunk: HunkId) -> HunkDecoration { |
|
| 27 | + | if hunk != HunkId::new(0) { |
|
| 28 | + | return HunkDecoration::default(); |
|
| 29 | + | } |
|
| 30 | + | HunkDecoration { |
|
| 31 | + | gutter: Some(Paint::new('โ').fg(colors::rgb::GREEN)), |
|
| 32 | + | corner: Line::new(Label::new("2 ๐ฉ").fg(colors::rgb::DIM)), |
|
| 33 | + | style: Some(Style::default().dim()), |
|
| 34 | + | } |
|
| 35 | + | } |
|
| 36 | + | } |
|
| 8 | 37 | ||
| 9 | 38 | #[test] |
|
| 10 | 39 | fn expanded_file_card_matches_golden_frame() { |
|
| 11 | 40 | assert_golden( |
|
| 12 | 41 | "expanded_file_card_64x9.txt", |
| 26 | 55 | 64, |
|
| 27 | 56 | 12, |
|
| 28 | 57 | ); |
|
| 29 | 58 | } |
|
| 30 | 59 | ||
| 60 | + | #[test] |
|
| 61 | + | fn review_hunk_gutter_matches_golden_frame() { |
|
| 62 | + | let mut viewer = two_hunk_viewer(); |
|
| 63 | + | viewer.set_decorator(ReviewDecorator); |
|
| 64 | + | ||
| 65 | + | assert_golden( |
|
| 66 | + | "review_hunk_gutter_64x12.txt", |
|
| 67 | + | include_str!("golden/review_hunk_gutter_64x12.txt"), |
|
| 68 | + | viewer, |
|
| 69 | + | 64, |
|
| 70 | + | 12, |
|
| 71 | + | ); |
|
| 72 | + | } |
|
| 73 | + | ||
| 31 | 74 | #[test] |
|
| 32 | 75 | fn file_summary_ignores_visible_hunks_and_context() { |
|
| 33 | 76 | let mut viewer = two_hunk_viewer(); |
|
| 34 | 77 | viewer |
|
| 35 | 78 | .load_file_locs(|_| Ok::<_, ()>(b"one\ntwo\nthree\nfour\nfive\nsix\n".to_vec())) |
a.rs
+0 -0
a.rs
+0 -0
crates/diff/tests/golden/bottom_of_file_64x5.txt
+1 -1
| 1 | 1 | โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ๐ฎ |
|
| 2 | 2 | โ โ a.rs 4 LOC +2 -1 โ๐ฎ |
|
| 3 | 3 | โโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโคโ |
|
| 4 | - | โ 3 4 tail โโ |
|
| 4 | + | โ 3 4 tail โโ |
|
| 5 | 5 | โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏโ |
crates/diff/tests/golden/expanded_context_focus_64x8.txt
+4 -4
| 1 | 1 | โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ๐ฎ |
|
| 2 | 2 | โ โ a.rs 4 LOC +2 -2 โ๐ฎ |
|
| 3 | 3 | โโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโค๐ฎ |
|
| 4 | - | โ 9 9 nine โ๐ฎ |
|
| 5 | - | โ 10 10 keep โโ |
|
| 6 | - | โ 11 - before โโ |
|
| 7 | - | โ 11 + after โโ |
|
| 4 | + | โ 9 9 nine โ๐ฎ |
|
| 5 | + | โ 10 10 keep โโ |
|
| 6 | + | โ 11 - before โโ |
|
| 7 | + | โ 11 + after โโ |
|
| 8 | 8 | โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏโ |
crates/diff/tests/golden/expanded_file_card_64x9.txt
+5 -5
| 1 | 1 | โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ๐ฎ |
|
| 2 | 2 | โ โ a.rs 4 LOC +2 -1 โ๐ฎ |
|
| 3 | 3 | โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค๐ฎ |
|
| 4 | - | โ 1 1 context โ๐ฎ |
|
| 5 | - | โ 2 - old โ๐ฎ |
|
| 6 | - | โ 2 + new โ๐ฎ |
|
| 7 | - | โ 3 + extra โ๐ฎ |
|
| 8 | - | โ 3 4 tail โ๐ฎ |
|
| 4 | + | โ 1 1 context โ๐ฎ |
|
| 5 | + | โ 2 - old โ๐ฎ |
|
| 6 | + | โ 2 + new โ๐ฎ |
|
| 7 | + | โ 3 + extra โ๐ฎ |
|
| 8 | + | โ 3 4 tail โ๐ฎ |
|
| 9 | 9 | โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ๐ฎ |
crates/diff/tests/golden/file_kinds_80x24.txt
+2 -2
| 1 | 1 | โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ๐ฎ |
|
| 2 | 2 | โ โ new.rs 1 LOC created +1 โ๐ฎ |
|
| 3 | 3 | โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค๐ฎ |
|
| 4 | - | โ 1 + new โ๐ฎ |
|
| 4 | + | โ 1 + new โ๐ฎ |
|
| 5 | 5 | โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ๐ฎ |
|
| 6 | 6 | โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ๐ฎ |
|
| 7 | 7 | โ โ old.rs 1 LOC deleted -1 โ๐ฎ |
|
| 8 | 8 | โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค๐ฎ |
|
| 9 | - | โ 1 - old โ๐ฎ |
|
| 9 | + | โ 1 - old โ๐ฎ |
|
| 10 | 10 | โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ๐ฎ |
|
| 11 | 11 | โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ๐ฎ |
|
| 12 | 12 | โ โฆ from.rs โ to.rs 0 LOC moved โ๐ฎ |
|
| 13 | 13 | โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ๐ฎ |
|
| 14 | 14 | โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ๐ฎ |
crates/diff/tests/golden/focused_second_file_64x6.txt
+3 -3
| 1 | 1 | โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ๐ฎ |
|
| 2 | 2 | โ โ b.rs 2 LOC +1 -1 โ๐ฎ |
|
| 3 | 3 | โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค๐ฎ |
|
| 4 | - | โ 1 1 keep โโ |
|
| 5 | - | โ 2 - before โโ |
|
| 6 | - | โ 2 + after โโ |
|
| 4 | + | โ 1 1 keep โโ |
|
| 5 | + | โ 2 - before โโ |
|
| 6 | + | โ 2 + after โโ |
crates/diff/tests/golden/highlighted_source_64x5.txt
+2 -2
| 1 | 1 | โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎโ |
|
| 2 | 2 | โ โ a.rs 4 LOC +2 -1 โโ |
|
| 3 | 3 | โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโคโ |
|
| 4 | - | โ 1 1 highlighted context โ๐ฎ |
|
| 5 | - | โ 2 - old โ๐ฎ |
|
| 4 | + | โ 1 1 highlighted context โ๐ฎ |
|
| 5 | + | โ 2 - old โ๐ฎ |
crates/diff/tests/golden/multi_hunk_gap_64x12.txt
+7 -7
| 1 | 1 | โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ๐ฎ |
|
| 2 | 2 | โ โ a.rs 4 LOC +2 -2 โ๐ฎ |
|
| 3 | 3 | โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค๐ฎ |
|
| 4 | - | โ 1 1 keep โ๐ฎ |
|
| 5 | - | โ 2 - old โ๐ฎ |
|
| 6 | - | โ 2 + new โ๐ฎ |
|
| 7 | - | โ โฎ โ๐ฎ |
|
| 8 | - | โ 10 10 keep โ๐ฎ |
|
| 9 | - | โ 11 - before โ๐ฎ |
|
| 10 | - | โ 11 + after โ๐ฎ |
|
| 4 | + | โ 1 1 keep โ๐ฎ |
|
| 5 | + | โ 2 - old โ๐ฎ |
|
| 6 | + | โ 2 + new โ๐ฎ |
|
| 7 | + | โ โฎ โ๐ฎ |
|
| 8 | + | โ 10 10 keep โ๐ฎ |
|
| 9 | + | โ 11 - before โ๐ฎ |
|
| 10 | + | โ 11 + after โ๐ฎ |
|
| 11 | 11 | โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ๐ฎ |
|
| 12 | 12 | ๐ฎ |
crates/diff/tests/golden/narrow_view_14x8.txt
+5 -5
| 1 | 1 | โญโโโโโโโโโโโโฎโ |
|
| 2 | 2 | โ โ a.rs 4โฆ โโ |
|
| 3 | 3 | โโโโโโโโโโโโโคโ |
|
| 4 | - | โ 1 1 โฆ โโ |
|
| 5 | - | โ 2 โฆ โโ |
|
| 6 | - | โ 2 โฆ โโ |
|
| 7 | - | โ 3 โฆ โโ |
|
| 8 | - | โ 3 4 โฆ โ๐ฎ |
|
| 4 | + | โ 1 1 โฆ โโ |
|
| 5 | + | โ 2 โฆ โโ |
|
| 6 | + | โ 2 โฆ โโ |
|
| 7 | + | โ 3 โฆ โโ |
|
| 8 | + | โ 3 4 โฆ โ๐ฎ |
crates/diff/tests/golden/preamble_and_no_newline_64x17.txt
+3 -3
| 9 | 9 | โ Message body text 2. โ๐ฎ |
|
| 10 | 10 | โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ๐ฎ |
|
| 11 | 11 | โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ๐ฎ |
|
| 12 | 12 | โ โ a.rs 1 LOC +1 -1 โ๐ฎ |
|
| 13 | 13 | โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค๐ฎ |
|
| 14 | - | โ 1 - old โ๐ฎ |
|
| 15 | - | โ 1 + new โ๐ฎ |
|
| 16 | - | โ \ No newline at end of file โ๐ฎ |
|
| 14 | + | โ 1 - old โ๐ฎ |
|
| 15 | + | โ 1 + new โ๐ฎ |
|
| 16 | + | โ \ No newline at end of file โ๐ฎ |
|
| 17 | 17 | โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ๐ฎ |
crates/diff/tests/golden/review_hunk_gutter_64x12.txt
added
+12 -0
| 1 | + | โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ๐ฎ |
|
| 2 | + | โ โ a.rs 4 LOC โโโโโโโโโโ โ๐ฎ |
|
| 3 | + | โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค๐ฎ |
|
| 4 | + | โ 1 1 keep 2 ๐ฉ โ๐ฎ |
|
| 5 | + | โ โ2 - old โ๐ฎ |
|
| 6 | + | โ โ 2 + new โ๐ฎ |
|
| 7 | + | โ โฎ โ๐ฎ |
|
| 8 | + | โ 10 10 keep โ๐ฎ |
|
| 9 | + | โ 11 - before โ๐ฎ |
|
| 10 | + | โ 11 + after โ๐ฎ |
|
| 11 | + | โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ๐ฎ |
|
| 12 | + | ๐ฎ |
crates/diff/tests/golden/stable_file_summary_64x9.txt
+6 -6
| 1 | 1 | โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎโ |
|
| 2 | 2 | โ โ a.rs 6 LOC +2 -2 โโ |
|
| 3 | 3 | โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโคโ |
|
| 4 | - | โ 7 7 context1 โโ |
|
| 5 | - | โ 8 8 context2 โโ |
|
| 6 | - | โ 9 9 context3 โโ |
|
| 7 | - | โ 10 10 context4 โโ |
|
| 8 | - | โ 11 - before โโ |
|
| 9 | - | โ 11 + after โ๐ฎ |
|
| 4 | + | โ 7 7 context1 โโ |
|
| 5 | + | โ 8 8 context2 โโ |
|
| 6 | + | โ 9 9 context3 โโ |
|
| 7 | + | โ 10 10 context4 โโ |
|
| 8 | + | โ 11 - before โโ |
|
| 9 | + | โ 11 + after โ๐ฎ |
crates/diff/tests/golden/sticky_header_before_next_file_64x5.txt
+1 -1
| 1 | 1 | โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ๐ฎ |
|
| 2 | 2 | โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ๐ฎ |
|
| 3 | 3 | โ โ b.rs 2 LOC +1 -1 โโ |
|
| 4 | 4 | โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโคโ |
|
| 5 | - | โ 1 1 keep โ๐ฎ |
|
| 5 | + | โ 1 1 keep โ๐ฎ |
crates/diff/tests/golden/sticky_header_inside_file_64x5.txt
+1 -1
| 1 | 1 | โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ๐ฎ |
|
| 2 | 2 | โ โ a.rs 4 LOC +2 -1 โ๐ฎ |
|
| 3 | 3 | โโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโคโ |
|
| 4 | - | โ 3 4 tail โโ |
|
| 4 | + | โ 3 4 tail โโ |
|
| 5 | 5 | โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏโ |
crates/diff/tests/golden/sticky_header_replaces_chrome_64x5.txt
+2 -2
| 1 | 1 | โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ๐ฎ |
|
| 2 | 2 | โ โ a.rs 4 LOC +2 -1 โโ |
|
| 3 | 3 | โโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโคโ |
|
| 4 | - | โ 3 + extra โโ |
|
| 5 | - | โ 3 4 tail โ๐ฎ |
|
| 4 | + | โ 3 + extra โโ |
|
| 5 | + | โ 3 4 tail โ๐ฎ |
crates/diff/tests/golden/sticky_header_starting_64x5.txt
+2 -2
| 1 | 1 | โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎโ |
|
| 2 | 2 | โ โ a.rs 4 LOC +2 -1 โโ |
|
| 3 | 3 | โโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโดโคโ |
|
| 4 | - | โ 2 - old โ๐ฎ |
|
| 5 | - | โ 2 + new โ๐ฎ |
|
| 4 | + | โ 2 - old โ๐ฎ |
|
| 5 | + | โ 2 + new โ๐ฎ |
crates/diff/tests/golden/wide_file_tree_120x12.txt
+5 -5
| 1 | 1 | โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎโ |
|
| 2 | 2 | โฟ rustik/ โ โ a.rs 4 LOC +2 -1 โโ |
|
| 3 | 3 | โ a.rs โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโคโ |
|
| 4 | - | โ b.rs โ 1 1 context โโ |
|
| 5 | - | โ 2 - old โโ |
|
| 6 | - | โ 2 + new โโ |
|
| 7 | - | โ 3 + extra โโ |
|
| 8 | - | โ 3 4 tail โโ |
|
| 4 | + | โ b.rs โ 1 1 context โโ |
|
| 5 | + | โ 2 - old โโ |
|
| 6 | + | โ 2 + new โโ |
|
| 7 | + | โ 3 + extra โโ |
|
| 8 | + | โ 3 4 tail โโ |
|
| 9 | 9 | โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏโ |
|
| 10 | 10 | โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ๐ฎ |
|
| 11 | 11 | โ โ b.rs 2 LOC +1 -1 โ๐ฎ |
|
| 12 | 12 | โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค๐ฎ |