mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Fix display of multiline strings when iterating over a list
When iterating over a list, the prefix is a dash followed by a space. However, the prefix was being prepended to each line of a string before adding it to the output. This means that each line of the string appears to be a distinct list element. This commit fixes this issue by only prepending the prefix on the first line of a multiline string. On all other lines, a prefix consisting of a number of spaces equal to the length of the prefix is used, ensuring that the mulitline string is consistently indented.
This commit is contained in:
parent
52cc07cec9
commit
761be9cb93
1 changed files with 4 additions and 1 deletions
|
@ -89,17 +89,20 @@ class NestDisplay(object):
|
|||
)
|
||||
)
|
||||
elif isinstance(ret, string_types):
|
||||
first_line = True
|
||||
for line in ret.splitlines():
|
||||
if self.strip_colors:
|
||||
line = salt.output.strip_esc_sequence(line)
|
||||
line_prefix = ' ' * len(prefix) if not first_line else prefix
|
||||
out.append(
|
||||
self.ustring(
|
||||
indent,
|
||||
self.GREEN,
|
||||
line,
|
||||
prefix=prefix
|
||||
prefix=line_prefix
|
||||
)
|
||||
)
|
||||
first_line = False
|
||||
elif isinstance(ret, (list, tuple)):
|
||||
for ind in ret:
|
||||
if isinstance(ind, (list, tuple, dict)):
|
||||
|
|
Loading…
Add table
Reference in a new issue