just playing with tangled
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

indent added/removed diffs with `+| ` or `-| `

I initially tried just `+` and `-`, but that seemed confusing. The color helps, but I think this is ~understandable either way

+31 -4
+31 -4
cli/src/diff_util.rs
··· 80 80 use unicode_width::UnicodeWidthStr as _; 81 81 82 82 use crate::config::CommandNameAndArgs; 83 + use crate::formatter::FormatRecorder; 83 84 use crate::formatter::Formatter; 84 85 use crate::merge_tools; 85 86 use crate::merge_tools::generate_diff; ··· 1143 1144 .block_on() 1144 1145 } 1145 1146 1147 + /// TODO: Rename, refactor, move? 1148 + fn print_indented( 1149 + formatter: &mut dyn Formatter, 1150 + write_prefix: impl FnMut(&mut dyn Formatter) -> io::Result<()>, 1151 + mut write_contents: impl FnMut(&mut dyn Formatter) -> io::Result<()>, 1152 + ) -> io::Result<()> { 1153 + let mut recorder = FormatRecorder::new(); 1154 + write_contents(&mut recorder)?; 1155 + text_util::write_indented(formatter, &recorder, write_prefix) 1156 + } 1157 + 1146 1158 fn show_structured_conflict_diff_hunks( 1147 1159 formatter: &mut dyn Formatter, 1148 1160 left: Merge<BString>, ··· 1180 1192 None 1181 1193 } 1182 1194 }; 1195 + // TODO: print_header with custom character, use +- for added/removed diffs 1196 + // or maybe *% for something. 1183 1197 let print_header = |formatter: &mut dyn Formatter, header: &str| { 1184 1198 writeln!(formatter.labeled("hunk_header"), "=========== {header}") 1185 1199 }; ··· 1205 1219 } 1206 1220 Ok(()) 1207 1221 }; 1222 + 1208 1223 // Some(None) means that last hunk was something other than unmodified 1209 1224 // text. 1210 1225 let mut last_hunk_unmodified_text: Option<Option<Vec<u8>>> = None; ··· 1233 1248 conflict_remove, 1234 1249 } => { 1235 1250 print_header(formatter, "Added Diff")?; 1236 - // TODO: Indent by `+` 1237 - show_diff(formatter, conflict_remove, conflict_add)?; 1251 + print_indented( 1252 + formatter, 1253 + |formatter| { 1254 + formatter.with_label("added", |f| f.write_all(b"+"))?; 1255 + formatter.with_label("separator", |f| f.write_all(b"| ")) 1256 + }, 1257 + |formatter| show_diff(formatter, conflict_remove, conflict_add), 1258 + )?; 1238 1259 } 1239 1260 DiffExplanationAtom::RemovedConflictDiff { 1240 1261 conflict_add, 1241 1262 conflict_remove, 1242 1263 } => { 1243 1264 print_header(formatter, "Removed Diff")?; 1244 - // TODO: Indent by `-` 1245 - show_diff(formatter, conflict_remove, conflict_add)?; 1265 + print_indented( 1266 + formatter, 1267 + |formatter| { 1268 + formatter.with_label("removed", |f| f.write_all(b"-"))?; 1269 + formatter.with_label("separator", |f| f.write_all(b"| ")) 1270 + }, 1271 + |formatter| show_diff(formatter, conflict_remove, conflict_add), 1272 + )?; 1246 1273 } 1247 1274 DiffExplanationAtom::ChangedConflictAdd { 1248 1275 left_version,