Skip to content

Commit f06062f

Browse files
committed
boxes: codehilite: 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 80 is used which is a reasonable limit for in a full screen no autohide mode.
1 parent 8602a7f commit f06062f

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
@@ -1417,9 +1417,11 @@ def indent_quoted_content(soup: Any, padding_char: str) -> int:
14171417
@staticmethod
14181418
def parse_codeblock(code_soup: Any) -> List[Any]:
14191419
markup = []
1420+
MAX_NO_WRAP_WIDTH = 80
14201421

14211422
code_text = code_soup.text
14221423
max_line_len = len(max(code_text.split("\n"), key=lambda x: len(x)))
1424+
max_line_len = min(max_line_len, MAX_NO_WRAP_WIDTH)
14231425

14241426
line_len = 0
14251427
for code_element in code_soup.contents:

0 commit comments

Comments
 (0)