Skip to content

Commit

Permalink
Correctly render non-string keys with square delimiters and no quotes…
Browse files Browse the repository at this point in the history
… in status bar.
  • Loading branch information
PaulJuliusMartinez committed Mar 3, 2022
1 parent 1f4ee89 commit 3fcb89d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/screenwriter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -446,9 +446,13 @@ impl ScreenWriter {
}

if let Some(key_range) = &row.key_range {
let key_open_delimiter = &viewer.flatjson.1[key_range.start..key_range.start + 1];
let key = &viewer.flatjson.1[key_range.start + 1..key_range.end - 1];

if JS_IDENTIFIER.is_match(key) {
// For non-string keys in YAML.
if key_open_delimiter == "[" {
write!(buf, "[{}]", key).unwrap();
} else if JS_IDENTIFIER.is_match(key) {
write!(buf, ".{}", key).unwrap();
} else {
write!(buf, "[\"{}\"]", key).unwrap();
Expand Down

0 comments on commit 3fcb89d

Please sign in to comment.