fix(content): preserve entries across toggles
This commit is contained in:
1 parent
6a0f8978b7
commit
4f5141760a
1 file changed
+29
-5
@@ -1947,9 +1947,11 @@ enum WatcherEventHandling {
|
||||
fn watcher_event_handling(kind: ¬ify::EventKind) -> WatcherEventHandling {
|
||||
match kind {
|
||||
notify::EventKind::Access(_) => WatcherEventHandling::Ignore,
|
||||
notify::EventKind::Create(_)
|
||||
| notify::EventKind::Modify(_)
|
||||
| notify::EventKind::Remove(_) => WatcherEventHandling::Paths,
|
||||
notify::EventKind::Create(_) | notify::EventKind::Remove(_) => WatcherEventHandling::Paths,
|
||||
notify::EventKind::Modify(notify::event::ModifyKind::Name(_)) => {
|
||||
WatcherEventHandling::Rescan
|
||||
}
|
||||
notify::EventKind::Modify(_) => WatcherEventHandling::Paths,
|
||||
notify::EventKind::Any | notify::EventKind::Other => WatcherEventHandling::Rescan,
|
||||
}
|
||||
}
|
||||
@@ -2146,8 +2148,8 @@ mod tests {
|
||||
|
||||
use super::{
|
||||
ContentListState, WatcherEventHandling, available_description_width,
|
||||
description_text_width, diff_event_paths, ellipsize, load_provider_icon,
|
||||
right_aligned_footer_spans, square_icon_columns, title_suffix_spans,
|
||||
description_text_width, diff_directory, diff_event_paths, ellipsize, load_provider_icon,
|
||||
read_dir_stems, right_aligned_footer_spans, square_icon_columns, title_suffix_spans,
|
||||
watcher_event_handling,
|
||||
};
|
||||
|
||||
@@ -2183,12 +2185,34 @@ mod tests {
|
||||
watcher_event_handling(¬ify::EventKind::Modify(notify::event::ModifyKind::Any)),
|
||||
WatcherEventHandling::Paths
|
||||
);
|
||||
assert_eq!(
|
||||
watcher_event_handling(¬ify::EventKind::Modify(notify::event::ModifyKind::Name(
|
||||
notify::event::RenameMode::Both
|
||||
))),
|
||||
WatcherEventHandling::Rescan
|
||||
);
|
||||
assert_eq!(
|
||||
watcher_event_handling(¬ify::EventKind::Any),
|
||||
WatcherEventHandling::Rescan
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn content_watcher_keeps_a_renamed_disabled_entry() {
|
||||
let temp = tempfile::tempdir().unwrap();
|
||||
let enabled = temp.path().join("example.jar");
|
||||
let disabled = temp.path().join("example.jar.disabled");
|
||||
std::fs::write(&enabled, b"mod").unwrap();
|
||||
let known = Arc::new(Mutex::new(read_dir_stems(temp.path(), ".jar")));
|
||||
|
||||
std::fs::rename(enabled, &disabled).unwrap();
|
||||
let diff = diff_directory(temp.path(), ".jar", None, &known).unwrap();
|
||||
|
||||
assert_eq!(diff.toggled, vec![("example".to_owned(), false, disabled)]);
|
||||
assert!(diff.removed.is_empty());
|
||||
assert!(diff.added.is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn irrelevant_watcher_paths_do_not_emit_an_empty_diff() {
|
||||
let temp = tempfile::tempdir().unwrap();
|
||||
|
||||
Reference in new issue
Block a user