difftreelog
refactor more intuitive code location mapping
in: master
1 file changed
crates/jrsonnet-evaluator/src/trace.rsdiffbeforeafterboth12 return vec![];12 return vec![];13 }13 }14 let mut line = 1;14 let mut line = 1;15 let mut column = 0;15 let mut column = 1;16 let max_offset = *offsets.iter().max().unwrap();16 let max_offset = *offsets.iter().max().unwrap();171718 let mut offset_map = offsets18 let mut offset_map = offsets42 with_no_known_line_ending.push(out_idx);42 with_no_known_line_ending.push(out_idx);43 out[out_idx].line = line;43 out[out_idx].line = line;44 out[out_idx].column = column;44 out[out_idx].column = column;45 out[out_idx].line_start_offset = this_line_offset + 1;45 out[out_idx].line_start_offset = this_line_offset;46 offset_map.pop();46 offset_map.pop();47 }47 }48 _ => {}48 _ => {}49 }49 }50 if ch == '\n' {50 if ch == '\n' {51 line += 1;51 line += 1;52 column = 0;52 column = 1;535354 for idx in with_no_known_line_ending.drain(..) {54 for idx in with_no_known_line_ending.drain(..) {55 out[idx].line_end_offset = pos;55 out[idx].line_end_offset = pos;56 }56 }57 this_line_offset = pos;57 this_line_offset = pos + 1;585859 if pos == max_offset + 1 {59 if pos == max_offset + 1 {60 break;60 break;84 CodeLocation {84 CodeLocation {85 line: 1,85 line: 1,86 column: 1,86 column: 1,87 line_start_offset: 1,87 line_start_offset: 0,88 line_end_offset: 1188 line_end_offset: 1189 },89 },90 CodeLocation {90 CodeLocation {91 line: 2,91 line: 2,92 column: 3,92 column: 3,93 line_start_offset: 12,93 line_start_offset: 11,94 line_end_offset: 6794 line_end_offset: 6795 }95 }96 ]96 ]