better span view
This commit is contained in:
parent
43e40b61e3
commit
fdfc08e88b
12 changed files with 612 additions and 206 deletions
|
|
@ -167,6 +167,7 @@ mod tests {
|
|||
use crate::tui::{
|
||||
filter::{Filter, FilterKind, Matcher, MatcherValue},
|
||||
log_viewer::filters::Filters,
|
||||
model::FieldsName,
|
||||
processing::Cursor,
|
||||
widgets::last_error::LastError,
|
||||
};
|
||||
|
|
@ -194,7 +195,7 @@ mod tests {
|
|||
#[test]
|
||||
fn get_message() {
|
||||
let c = parse(&[with_fields(r#"{"message": "foo"}"#)].join("\n"));
|
||||
assert_eq!(c.curr().message_or_name(), Some("foo".to_string()));
|
||||
assert_eq!(c.curr().message_or_name(), Some("foo"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
@ -202,12 +203,12 @@ mod tests {
|
|||
let mut c = parse(&[with_fields(r#"{"message": "foo"}"#)].join("\n"));
|
||||
let f = filters();
|
||||
|
||||
assert_eq!(c.curr().message_or_name(), Some("foo".to_string()));
|
||||
assert_eq!(c.curr().message_or_name(), Some("foo"));
|
||||
assert!(!c.next(&f));
|
||||
assert!(!c.prev(&f));
|
||||
assert!(!c.enter(&f));
|
||||
assert!(!c.exit(&f));
|
||||
assert_eq!(c.curr().message_or_name(), Some("foo".to_string()));
|
||||
assert_eq!(c.curr().message_or_name(), Some("foo"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
@ -221,17 +222,17 @@ mod tests {
|
|||
);
|
||||
let f = filters();
|
||||
|
||||
assert_eq!(c.curr().message_or_name(), Some("foo".to_string()));
|
||||
assert_eq!(c.curr().message_or_name(), Some("foo"));
|
||||
assert!(c.next(&f));
|
||||
assert_eq!(c.curr().message_or_name(), Some("bar".to_string()));
|
||||
assert_eq!(c.curr().message_or_name(), Some("bar"));
|
||||
assert!(!c.next(&f));
|
||||
assert_eq!(c.curr().message_or_name(), Some("bar".to_string()));
|
||||
assert_eq!(c.curr().message_or_name(), Some("bar"));
|
||||
assert!(c.prev(&f));
|
||||
assert_eq!(c.curr().message_or_name(), Some("foo".to_string()));
|
||||
assert_eq!(c.curr().message_or_name(), Some("foo"));
|
||||
assert!(!c.prev(&f));
|
||||
assert!(!c.enter(&f));
|
||||
assert!(!c.exit(&f));
|
||||
assert_eq!(c.curr().message_or_name(), Some("foo".to_string()));
|
||||
assert_eq!(c.curr().message_or_name(), Some("foo"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
@ -249,14 +250,14 @@ mod tests {
|
|||
);
|
||||
let f = filters();
|
||||
|
||||
assert_eq!(c.curr().message_or_name(), Some("foo".to_string()));
|
||||
assert_eq!(c.curr().message_or_name(), Some("foo"));
|
||||
assert!(c.next(&f));
|
||||
assert!(matches!(Gc::as_ref(&c.curr()), LogEntry::Sub { .. }));
|
||||
assert!(c.next(&f));
|
||||
assert_eq!(c.curr().message_or_name(), Some("bar".to_string()));
|
||||
assert_eq!(c.curr().message_or_name(), Some("bar"));
|
||||
assert!(c.prev(&f));
|
||||
assert!(c.enter(&f));
|
||||
assert_eq!(c.curr().message_or_name(), Some("baz".to_string()));
|
||||
assert_eq!(c.curr().message_or_name(), Some("baz"));
|
||||
assert!(!c.enter(&f));
|
||||
assert!(!c.prev(&f));
|
||||
assert!(c.exit(&f));
|
||||
|
|
@ -265,7 +266,7 @@ mod tests {
|
|||
assert!(c.next(&f));
|
||||
assert!(!c.enter(&f));
|
||||
assert!(!c.next(&f));
|
||||
assert_eq!(c.curr().message_or_name(), Some("meow".to_string()));
|
||||
assert_eq!(c.curr().message_or_name(), Some("meow"));
|
||||
assert!(c.exit(&f));
|
||||
}
|
||||
|
||||
|
|
@ -282,7 +283,7 @@ mod tests {
|
|||
);
|
||||
let f = filters();
|
||||
|
||||
assert_eq!(c.curr().message_or_name(), Some("foo".to_string()));
|
||||
assert_eq!(c.curr().message_or_name(), Some("foo"));
|
||||
assert!(c.next(&f));
|
||||
assert!(
|
||||
matches!(Gc::as_ref(&c.curr()), LogEntry::Sub { children, .. } if children.first_child.is_none() )
|
||||
|
|
@ -291,7 +292,7 @@ mod tests {
|
|||
assert!(!c.exit(&f));
|
||||
assert!(matches!(Gc::as_ref(&c.curr()), LogEntry::Sub { .. }));
|
||||
assert!(c.next(&f));
|
||||
assert_eq!(c.curr().message_or_name(), Some("bar".to_string()));
|
||||
assert_eq!(c.curr().message_or_name(), Some("bar"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
@ -310,12 +311,13 @@ mod tests {
|
|||
matcher: Matcher::Field {
|
||||
name: "message".to_string(),
|
||||
value: MatcherValue::Exact("foo".to_string()),
|
||||
span: FieldsName::Main,
|
||||
},
|
||||
kind: FilterKind::Remove,
|
||||
}));
|
||||
|
||||
assert!(c.next(&f));
|
||||
assert_eq!(c.curr().message_or_name(), Some("baz".to_string()));
|
||||
assert_eq!(c.curr().message_or_name(), Some("baz"));
|
||||
assert!(!c.prev(&f));
|
||||
}
|
||||
|
||||
|
|
@ -335,15 +337,16 @@ mod tests {
|
|||
matcher: Matcher::Field {
|
||||
name: "message".to_string(),
|
||||
value: MatcherValue::Exact("baz".to_string()),
|
||||
span: FieldsName::Main,
|
||||
},
|
||||
kind: FilterKind::Remove,
|
||||
}));
|
||||
|
||||
assert_eq!(c.curr().message_or_name(), Some("foo".to_string()));
|
||||
assert_eq!(c.curr().message_or_name(), Some("foo"));
|
||||
assert!(c.next(&f));
|
||||
assert_eq!(c.curr().message_or_name(), Some("meow".to_string()));
|
||||
assert_eq!(c.curr().message_or_name(), Some("meow"));
|
||||
assert!(c.prev(&f));
|
||||
assert_eq!(c.curr().message_or_name(), Some("foo".to_string()));
|
||||
assert_eq!(c.curr().message_or_name(), Some("foo"));
|
||||
assert!(!c.prev(&f));
|
||||
}
|
||||
|
||||
|
|
@ -365,25 +368,26 @@ mod tests {
|
|||
matcher: Matcher::Field {
|
||||
name: "name".to_string(),
|
||||
value: MatcherValue::Exact("nest".to_string()),
|
||||
span: FieldsName::Main,
|
||||
},
|
||||
kind: FilterKind::Inline,
|
||||
}));
|
||||
|
||||
assert_eq!(c.curr().message_or_name(), Some("foo".to_string()));
|
||||
assert_eq!(c.curr().message_or_name(), Some("foo"));
|
||||
assert!(c.next(&f));
|
||||
assert_eq!(c.curr().message_or_name(), Some("baz".to_string()));
|
||||
assert_eq!(c.curr().message_or_name(), Some("baz"));
|
||||
assert!(c.next(&f));
|
||||
assert!(!c.exit(&f));
|
||||
assert_eq!(c.curr().message_or_name(), Some("meow".to_string()));
|
||||
assert_eq!(c.curr().message_or_name(), Some("meow"));
|
||||
assert!(c.next(&f));
|
||||
assert_eq!(c.curr().message_or_name(), Some("bar".to_string()));
|
||||
assert_eq!(c.curr().message_or_name(), Some("bar"));
|
||||
assert!(c.prev(&f));
|
||||
assert_eq!(c.curr().message_or_name(), Some("meow".to_string()));
|
||||
assert_eq!(c.curr().message_or_name(), Some("meow"));
|
||||
assert!(!c.exit(&f));
|
||||
assert!(c.prev(&f));
|
||||
assert_eq!(c.curr().message_or_name(), Some("baz".to_string()));
|
||||
assert_eq!(c.curr().message_or_name(), Some("baz"));
|
||||
assert!(c.prev(&f));
|
||||
assert_eq!(c.curr().message_or_name(), Some("foo".to_string()));
|
||||
assert_eq!(c.curr().message_or_name(), Some("foo"));
|
||||
assert!(!c.prev(&f));
|
||||
}
|
||||
|
||||
|
|
@ -402,38 +406,39 @@ mod tests {
|
|||
);
|
||||
let mut f = filters();
|
||||
|
||||
assert_eq!(c.curr().message_or_name(), Some("foo".to_string()));
|
||||
assert_eq!(c.curr().message_or_name(), Some("foo"));
|
||||
assert!(c.next(&f));
|
||||
assert!(c.enter(&f));
|
||||
assert_eq!(c.curr().message_or_name(), Some("baz".to_string()));
|
||||
assert_eq!(c.curr().message_or_name(), Some("baz"));
|
||||
// inline the current item
|
||||
f.push(Arc::new(Filter {
|
||||
matcher: Matcher::Field {
|
||||
name: "name".to_string(),
|
||||
value: MatcherValue::Exact("nest".to_string()),
|
||||
span: FieldsName::Main,
|
||||
},
|
||||
kind: FilterKind::Inline,
|
||||
}));
|
||||
c.update_with_parents(&f);
|
||||
assert_eq!(c.curr().message_or_name(), Some("baz".to_string()));
|
||||
assert_eq!(c.curr().message_or_name(), Some("baz"));
|
||||
println!("undo");
|
||||
f.undo();
|
||||
c.update_with_parents(&f);
|
||||
assert_eq!(c.curr().message_or_name(), Some("nest".to_string()));
|
||||
assert_eq!(c.curr().message_or_name(), Some("nest"));
|
||||
assert!(c.next(&f));
|
||||
assert_eq!(c.curr().message_or_name(), Some("bar".to_string()));
|
||||
assert_eq!(c.curr().message_or_name(), Some("bar"));
|
||||
assert!(!c.next(&f));
|
||||
assert!(c.prev(&f));
|
||||
assert!(c.enter(&f));
|
||||
assert_eq!(c.curr().message_or_name(), Some("baz".to_string()));
|
||||
assert_eq!(c.curr().message_or_name(), Some("baz"));
|
||||
assert!(c.next(&f));
|
||||
assert_eq!(c.curr().message_or_name(), Some("meow".to_string()));
|
||||
assert_eq!(c.curr().message_or_name(), Some("meow"));
|
||||
f.redo();
|
||||
c.update_with_parents(&f);
|
||||
// redo inlines, and goes to start of inlined part
|
||||
assert_eq!(c.curr().message_or_name(), Some("baz".to_string()));
|
||||
assert_eq!(c.curr().message_or_name(), Some("baz"));
|
||||
assert!(c.prev(&f));
|
||||
assert_eq!(c.curr().message_or_name(), Some("foo".to_string()));
|
||||
assert_eq!(c.curr().message_or_name(), Some("foo"));
|
||||
assert!(!c.prev(&f));
|
||||
}
|
||||
|
||||
|
|
@ -452,7 +457,7 @@ mod tests {
|
|||
let mut f = filters();
|
||||
c.enter(&f);
|
||||
c.enter(&f);
|
||||
assert_eq!(c.curr().message_or_name(), Some("baz".to_string()));
|
||||
assert_eq!(c.curr().message_or_name(), Some("baz"));
|
||||
c.exit(&f);
|
||||
c.exit(&f);
|
||||
|
||||
|
|
@ -460,6 +465,7 @@ mod tests {
|
|||
matcher: Matcher::Field {
|
||||
name: "name".to_string(),
|
||||
value: MatcherValue::Exact("nest1".to_string()),
|
||||
span: FieldsName::Main,
|
||||
},
|
||||
kind: FilterKind::Inline,
|
||||
}));
|
||||
|
|
@ -467,11 +473,12 @@ mod tests {
|
|||
matcher: Matcher::Field {
|
||||
name: "name".to_string(),
|
||||
value: MatcherValue::Exact("nest2".to_string()),
|
||||
span: FieldsName::Main,
|
||||
},
|
||||
kind: FilterKind::Inline,
|
||||
}));
|
||||
c.update_with_parents(&f);
|
||||
|
||||
assert_eq!(c.curr().message_or_name(), Some("baz".to_string()));
|
||||
assert_eq!(c.curr().message_or_name(), Some("baz"));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue