Display paths properly

patch_format
Wilfred Hughes 2024-02-08 08:30:10 +07:00
parent 81fa1c7096
commit 7c9e14f55f
2 changed files with 12 additions and 8 deletions

@ -4,23 +4,27 @@ use crate::constants::Side;
use crate::diff::myers_diff;
use crate::display::style::apply_colors;
use crate::line_parser::split_lines_keep_newline;
use crate::options::DisplayOptions;
use crate::options::{DisplayOptions, FileArgument};
use crate::parse::syntax::MatchedPos;
use crate::summary::FileFormat;
use super::style::apply_header_color;
fn header(display_options: &DisplayOptions, lhs_path: &str, rhs_path: &str) -> String {
fn header(
display_options: &DisplayOptions,
lhs_path: &FileArgument,
rhs_path: &FileArgument,
) -> String {
let mut s = String::new();
s.push_str(&apply_header_color(
&format!("--- {}", lhs_path),
&format!("--- {}", lhs_path.display()),
display_options.use_color,
display_options.background_color,
1,
));
s.push('\n');
s.push_str(&apply_header_color(
&format!("+++ {}", rhs_path),
&format!("+++ {}", rhs_path.display()),
display_options.use_color,
display_options.background_color,
1,
@ -32,8 +36,8 @@ fn header(display_options: &DisplayOptions, lhs_path: &str, rhs_path: &str) -> S
pub(crate) fn print(
display_options: &DisplayOptions,
file_format: &FileFormat,
lhs_path: &str,
rhs_path: &str,
lhs_path: &FileArgument,
rhs_path: &FileArgument,
lhs_src: &str,
rhs_src: &str,
lhs_mps: &[MatchedPos],

@ -909,8 +909,8 @@ fn print_diff_result(display_options: &DisplayOptions, summary: &DiffResult) {
DisplayMode::Patch => display::patch::print(
display_options,
&summary.file_format,
&summary.display_path,
"foo.el",
&summary.lhs_path,
&summary.rhs_path,
lhs_src,
rhs_src,
&summary.lhs_positions,