Debian Codegraph @

src/handlers/mod.rs

raw symbols SCIP
1 /// This module contains functions handling input lines encountered during the
2 /// main `StateMachine::consume()` loop.
3 pub mod blame;
4 pub mod commit_meta;
5 pub mod diff_header;
6 pub mod diff_header_diff;
7 pub mod diff_header_misc;
8 pub mod diff_stat;
9 pub mod draw;
10 pub mod git_show_file;
11 pub mod grep;
12 pub mod hunk;
13 pub mod hunk_header;
14 pub mod merge_conflict;
15 mod ripgrep_json;
16 pub mod submodule;
17
18 use crate::delta::{State, StateMachine};
19
20 impl StateMachine<'_> {
21 pub fn handle_additional_cases(&mut self, to_state: State) -> std::io::Result<bool> {
22 let mut handled_line = false;
23
24 // Additional cases:
25 //
26 // 1. When comparing directories with diff -u, if filenames match between the
27 // directories, the files themselves will be compared. However, if an equivalent
28 // filename is not present, diff outputs a single line (Only in...) starting
29 // indicating that the file is present in only one of the directories.
30 //
31 // 2. Git diff emits lines describing submodule state such as "Submodule x/y/z contains
32 // untracked content"
33 //
34 // 3. When comparing binary files, diff can emit "Binary files ... differ" line.
35 //
36 // See https://github.com/dandavison/delta/issues/60#issuecomment-557485242 for a
37 // proposal for more robust parsing logic.
38
39 self.painter.paint_buffered_minus_and_plus_lines();
40 self.state = to_state;
41 if self.should_handle() {
42 self.painter.emit()?;
43 diff_header::write_generic_diff_header_header_line(
44 &self.line,
45 &self.raw_line,
46 &mut self.painter,
47 &mut self.mode_info,
48 self.config,
49 )?;
50 handled_line = true;
51 }
52
53 Ok(handled_line)
54 }
55 }