Skip to content

Commit 6e03640

Browse files
committed
boxes: Restrict padding to avoid wrapping.
This commit sets a limit to how much padding is to be added. Many a times most of the code has smaller lines and there is one line which is very long which causes all the lines to wrap and this makes the "box" look very messy. To avoid this a `MAX_NO_WRAP_WIDTH` constant of 70 is used which is a reasonable limit for in a full screen no autohide mode.
1 parent 04ba110 commit 6e03640

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

zulipterminal/ui_tools/boxes.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1595,10 +1595,12 @@ def parse_codeblock(code_soup: Any) -> List[Any]:
15951595
it would have <pre><span></span>xxx</pre>
15961596
"""
15971597
markup = []
1598+
MAX_NO_WRAP_WIDTH = 60
15981599

15991600
# Find longest line
16001601
code_text = code_soup.text
16011602
max_line_len = len(max(code_text.split("\n"), key=lambda x: len(x)))
1603+
max_line_len = min(max_line_len, MAX_NO_WRAP_WIDTH)
16021604

16031605
line_len = 0
16041606
for code_element in code_soup.contents:

0 commit comments

Comments
 (0)