MCPcopy Create free account
hub / github.com/Mic92/nix-diff-rs / format_text_diff_limits_context

Function format_text_diff_limits_context

src/render.rs:884–908  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

882
883 #[test]
884 fn format_text_diff_limits_context() {
885 // With context_lines=1, only 1 context line should surround a change.
886 let renderer = Renderer::new(RenderOptions {
887 color_mode: ColorMode::Never,
888 context_lines: 1,
889 ..Default::default()
890 });
891 let old = b"a\nb\nc\nd\ne\n";
892 let new = b"a\nb\nNEW\nc\nd\ne\n";
893
894 let mut out = Vec::new();
895 renderer.format_text_diff(&mut out, old, new, 0);
896 let out = String::from_utf8(out).unwrap();
897
898 // Leading: only "b" (1 line before change), then NEW, then only "c"
899 assert!(!out.contains(" a\n"), "leading context not limited: {out}");
900 assert!(out.contains(" b\n"));
901 assert!(out.contains("+ NEW\n"));
902 assert!(out.contains(" c\n"));
903 assert!(
904 !out.contains(" d\n"),
905 "trailing context not limited: {out}"
906 );
907 assert!(!out.contains(" e\n"));
908 }
909
910 #[test]
911 fn inline_highlight_marks_changed_words() {

Callers

nothing calls this directly

Calls 1

format_text_diffMethod · 0.80

Tested by

no test coverage detected