ratatui_toolkit/widgets/code_diff/foundation/diff_hunk/constructors/new.rs
1use crate::widgets::code_diff::diff_hunk::DiffHunk;
2
3impl DiffHunk {
4 /// Creates a new diff hunk with the specified line ranges.
5 ///
6 /// # Arguments
7 ///
8 /// * `old_start` - Starting line number in the old file
9 /// * `old_count` - Number of lines from the old file
10 /// * `new_start` - Starting line number in the new file
11 /// * `new_count` - Number of lines from the new file
12 ///
13 /// # Returns
14 ///
15 /// A new `DiffHunk` with empty lines and no context
16 ///
17 /// # Example
18 ///
19 /// ```rust
20 /// use ratatui_toolkit::code_diff::DiffHunk;
21 ///
22 /// let hunk = DiffHunk::new(1, 4, 1, 5);
23 /// assert_eq!(hunk.old_start, 1);
24 /// assert_eq!(hunk.old_count, 4);
25 /// ```
26 pub fn new(old_start: usize, old_count: usize, new_start: usize, new_count: usize) -> Self {
27 Self {
28 old_start,
29 old_count,
30 new_start,
31 new_count,
32 context: None,
33 lines: Vec::new(),
34 }
35 }
36}