summaryrefslogtreecommitdiff
path: root/cmd2/table_creator.py
diff options
context:
space:
mode:
authorKevin Van Brunt <kmvanbrunt@gmail.com>2021-03-02 09:46:28 -0500
committerKevin Van Brunt <kmvanbrunt@gmail.com>2021-03-02 09:46:28 -0500
commit6b14aa6579d9c5bdd32bf8c3d67f11db8b575bb0 (patch)
tree9fb1943c792e2d35fda3d02ae853d41f8ce8c917 /cmd2/table_creator.py
parentd4035b43d3a7edda50908f2e6bb090381831975d (diff)
downloadcmd2-git-6b14aa6579d9c5bdd32bf8c3d67f11db8b575bb0.tar.gz
Moved empty line check in table creator
Diffstat (limited to 'cmd2/table_creator.py')
-rw-r--r--cmd2/table_creator.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/cmd2/table_creator.py b/cmd2/table_creator.py
index d159ddbf..3b0db7b3 100644
--- a/cmd2/table_creator.py
+++ b/cmd2/table_creator.py
@@ -309,6 +309,11 @@ class TableCreator:
if data_line_index > 0:
wrapped_buf.write('\n')
+ # If the last line is empty, then add a newline and stop
+ if data_line_index == len(data_str_lines) - 1 and not data_line:
+ wrapped_buf.write('\n')
+ break
+
# Locate the styles in this line
styles = utils.get_styles_in_text(data_line)
@@ -351,10 +356,6 @@ class TableCreator:
last_word = data_line_index == len(data_str_lines) - 1 and char_index == len(data_line)
add_word(cur_word_buf.getvalue(), last_word)
- # If the last line is empty, then add a newline
- elif data_line_index == len(data_str_lines) - 1:
- wrapped_buf.write('\n')
-
# Stop line loop if we've written to max_lines
if total_lines == max_lines:
# If this isn't the last data line and there is space