mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 15:44:59 +02:00
Search nested structures recursively in find
command (#15850)
# Description Instead of converting nested structures into strings and pattern-matching the strings, the `find` command will recursively search the nested structures for matches. - fixes #15618 # User-Facing Changes Text in nested structures will now be highlighted as well. Error values will always passed on instead of testing them against the search term There will be slight changes in match behavior, such as characters that are part of the string representations of data structures no longer matching all nested data structures.
This commit is contained in:
@ -293,3 +293,20 @@ fn find_with_string_search_with_special_char_6() {
|
||||
);
|
||||
assert_eq!(actual_no_highlight.out, "[{\"d\":\"a[]b\"}]");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn find_in_nested_list_dont_match_bracket() {
|
||||
let actual = nu!(r#"[ [foo bar] [foo baz] ] | find "[" | to json -r"#);
|
||||
|
||||
assert_eq!(actual.out, "[]");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn find_and_highlight_in_nested_list() {
|
||||
let actual = nu!(r#"[ [foo bar] [foo baz] ] | find "foo" | to json -r"#);
|
||||
|
||||
assert_eq!(
|
||||
actual.out,
|
||||
r#"[["\u001b[37m\u001b[0m\u001b[41;37mfoo\u001b[0m\u001b[37m\u001b[0m","bar"],["\u001b[37m\u001b[0m\u001b[41;37mfoo\u001b[0m\u001b[37m\u001b[0m","baz"]]"#
|
||||
);
|
||||
}
|
||||
|
Reference in New Issue
Block a user