Skip to content

Commit

Permalink
more formatting: put first item on new line, keeps subsequent items i…
Browse files Browse the repository at this point in the history
…nline

Signed-off-by: Atif Ali <atali@redhat.com>
  • Loading branch information
aali309 committed Jan 8, 2025
1 parent 43bd500 commit f564f6e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions ui/src/app/shared/components/yaml-editor/yaml-editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ const formatYamlWithArrays = (input: any): string => {
noArrayIndent: false
});

// Add newline after dash for nested objects
yaml = yaml.replace(/^(\s*)-\s+(\w+):/gm, '$1-\n$1 $2:');
// Format nested arrays to improve readability when collapsed
//- puts first item on new line, keeps subsequent items inline
yaml = yaml.replace(/:(\s*)\n(\s*)-(\s+)(\w+):(\s*)\n(\s*)-/, ':$1\n$2-\n$2 $4:$5\n$6-');

return yaml;
};
Expand Down

0 comments on commit f564f6e

Please # to comment.