Revert "Show ? for optional entries when displaying CellPaths (#14042)"

This reverts commit 03015ed33f.
This commit is contained in:
Darren Schroeder
2024-11-02 08:03:45 -05:00
committed by GitHub
parent ccab3d6b6e
commit ac111e547e
2 changed files with 6 additions and 15 deletions

View File

@ -166,7 +166,7 @@ fn select_ignores_errors_successfully1() {
fn select_ignores_errors_successfully2() { fn select_ignores_errors_successfully2() {
let actual = nu!("[{a: 1} {a: 2} {a: 3}] | select b? | to nuon"); let actual = nu!("[{a: 1} {a: 2} {a: 3}] | select b? | to nuon");
assert_eq!(actual.out, "[[b?]; [null], [null], [null]]".to_string()); assert_eq!(actual.out, "[[b]; [null], [null], [null]]".to_string());
assert!(actual.err.is_empty()); assert!(actual.err.is_empty());
} }
@ -174,7 +174,7 @@ fn select_ignores_errors_successfully2() {
fn select_ignores_errors_successfully3() { fn select_ignores_errors_successfully3() {
let actual = nu!("{foo: bar} | select invalid_key? | to nuon"); let actual = nu!("{foo: bar} | select invalid_key? | to nuon");
assert_eq!(actual.out, "{invalid_key?: null}".to_string()); assert_eq!(actual.out, "{invalid_key: null}".to_string());
assert!(actual.err.is_empty()); assert!(actual.err.is_empty());
} }
@ -184,10 +184,7 @@ fn select_ignores_errors_successfully4() {
r#""key val\na 1\nb 2\n" | lines | split column --collapse-empty " " | select foo? | to nuon"# r#""key val\na 1\nb 2\n" | lines | split column --collapse-empty " " | select foo? | to nuon"#
); );
assert_eq!( assert_eq!(actual.out, r#"[[foo]; [null], [null], [null]]"#.to_string());
actual.out,
r#"[[foo?]; [null], [null], [null]]"#.to_string()
);
assert!(actual.err.is_empty()); assert!(actual.err.is_empty());
} }
@ -237,7 +234,7 @@ fn ignore_errors_works() {
[{}] | select -i $path | to nuon [{}] | select -i $path | to nuon
"#); "#);
assert_eq!(actual.out, "[[foo?]; [null]]"); assert_eq!(actual.out, "[[foo]; [null]]");
} }
#[test] #[test]

View File

@ -182,14 +182,8 @@ impl Display for CellPath {
write!(f, ".")?; write!(f, ".")?;
} }
match elem { match elem {
PathMember::Int { val, optional, .. } => { PathMember::Int { val, .. } => write!(f, "{val}")?,
let question_mark = if *optional { "?" } else { "" }; PathMember::String { val, .. } => write!(f, "{val}")?,
write!(f, "{val}{question_mark}")?
}
PathMember::String { val, optional, .. } => {
let question_mark = if *optional { "?" } else { "" };
write!(f, "{val}{question_mark}")?
}
} }
} }
Ok(()) Ok(())