mirror of https://github.com/helix-editor/helix
use doc path for modification time
parent
a9f2ec3eea
commit
b01329eb10
|
@ -185,7 +185,7 @@ pub struct Document {
|
||||||
|
|
||||||
// Last time we wrote to the file. This will carry the time the file was last opened if there
|
// Last time we wrote to the file. This will carry the time the file was last opened if there
|
||||||
// were no saves.
|
// were no saves.
|
||||||
pub last_saved_time: SystemTime,
|
last_saved_time: SystemTime,
|
||||||
|
|
||||||
last_saved_revision: usize,
|
last_saved_revision: usize,
|
||||||
version: i32, // should be usize?
|
version: i32, // should be usize?
|
||||||
|
|
|
@ -152,29 +152,40 @@ pub fn coverage<'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 Ok(coverage_path) = std::env::var("HELIX_COVERAGE_FILE") {
|
if let Ok(coverage_path) = std::env::var("HELIX_COVERAGE_FILE") {
|
||||||
|
log::debug!("coverage file is {}", coverage_path);
|
||||||
if let Some(cov) = coverage::parse(PathBuf::from(coverage_path)) {
|
if let Some(cov) = coverage::parse(PathBuf::from(coverage_path)) {
|
||||||
|
log::debug!("coverage is valid");
|
||||||
if let Some(mut path) = doc.path.clone() {
|
if let Some(mut path) = doc.path.clone() {
|
||||||
|
log::debug!("full document path: {:?}", path);
|
||||||
if let Ok(cwd) = std::env::current_dir() {
|
if let Ok(cwd) = std::env::current_dir() {
|
||||||
if let Ok(tmp) = path.strip_prefix(cwd) {
|
if let Ok(tmp) = path.strip_prefix(cwd) {
|
||||||
path = tmp.into();
|
path = tmp.into();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
log::debug!("relative document path: {:?}", path);
|
||||||
if let Some(file_coverage) = cov.files.get(&path) {
|
if let Some(file_coverage) = cov.files.get(&path) {
|
||||||
if file_coverage
|
log::debug!(
|
||||||
.modified_time
|
"coverage time: {:?} document time: {:?}",
|
||||||
.is_some_and(|x| x > doc.last_saved_time)
|
file_coverage.modified_time,
|
||||||
{
|
path.metadata().map(|meta| meta.modified())
|
||||||
|
);
|
||||||
|
if let Some(coverage_time) = file_coverage.modified_time {
|
||||||
|
if path.metadata().is_ok_and(|meta| {
|
||||||
|
meta.modified().is_ok_and(|time| time < coverage_time)
|
||||||
|
}) {
|
||||||
// clone file coverage so it can be moved into the closure
|
// clone file coverage so it can be moved into the closure
|
||||||
let this_file = coverage::FileCoverage {
|
let this_file = coverage::FileCoverage {
|
||||||
lines: file_coverage.lines.clone(),
|
lines: file_coverage.lines.clone(),
|
||||||
modified_time: file_coverage.modified_time,
|
modified_time: file_coverage.modified_time,
|
||||||
};
|
};
|
||||||
|
log::debug!("return valid coverage gutter");
|
||||||
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 {
|
} else {
|
||||||
|
@ -192,6 +203,8 @@ pub fn coverage<'doc>(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
log::debug!("return empty coverage gutter");
|
||||||
return Box::new(move |_, _, _, _| None);
|
return Box::new(move |_, _, _, _| None);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue