mirror of https://github.com/helix-editor/helix
load coverage file from environment variable
parent
6006a69b44
commit
79b85030b2
|
@ -151,35 +151,37 @@ pub fn coverage<'doc>(
|
||||||
) -> GutterFn<'doc> {
|
) -> GutterFn<'doc> {
|
||||||
let covered = theme.get("diff.plus.gutter");
|
let covered = theme.get("diff.plus.gutter");
|
||||||
let not_covered = theme.get("diff.minus.gutter");
|
let not_covered = theme.get("diff.minus.gutter");
|
||||||
if let Some(cov) = coverage::parse(PathBuf::from("report/coverage.xml")) {
|
if let Ok(coverage_path) = std::env::var("HELIX_COVERAGE_FILE") {
|
||||||
if let Some(mut path) = doc.path.clone() {
|
if let Some(cov) = coverage::parse(PathBuf::from(coverage_path)) {
|
||||||
if let Ok(cwd) = std::env::current_dir() {
|
if let Some(mut path) = doc.path.clone() {
|
||||||
if let Ok(tmp) = path.strip_prefix(cwd) {
|
if let Ok(cwd) = std::env::current_dir() {
|
||||||
path = tmp.into();
|
if let Ok(tmp) = path.strip_prefix(cwd) {
|
||||||
|
path = tmp.into();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
if let Some(file) = cov.files.get(&path) {
|
||||||
if let Some(file) = cov.files.get(&path) {
|
let this_file = coverage::FileCoverage {
|
||||||
let this_file = coverage::FileCoverage {
|
lines: file.lines.clone(),
|
||||||
lines: file.lines.clone(),
|
};
|
||||||
};
|
return Box::new(
|
||||||
return Box::new(
|
move |line: usize,
|
||||||
move |line: usize,
|
_selected: bool,
|
||||||
_selected: bool,
|
_first_visual_line: bool,
|
||||||
_first_visual_line: bool,
|
out: &mut String| {
|
||||||
out: &mut String| {
|
if let Some(line_coverage) = this_file.lines.get(&(line as u32)) {
|
||||||
if let Some(line_coverage) = this_file.lines.get(&(line as u32)) {
|
let (icon, style) = if *line_coverage {
|
||||||
let (icon, style) = if *line_coverage {
|
("┃", covered)
|
||||||
("┃", covered)
|
} else {
|
||||||
|
("┃", not_covered)
|
||||||
|
};
|
||||||
|
write!(out, "{}", icon).unwrap();
|
||||||
|
Some(style)
|
||||||
} else {
|
} else {
|
||||||
("┃", not_covered)
|
None
|
||||||
};
|
}
|
||||||
write!(out, "{}", icon).unwrap();
|
},
|
||||||
Some(style)
|
);
|
||||||
} else {
|
}
|
||||||
None
|
|
||||||
}
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue