-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Closed
Labels
Description
- I've checked docs and closed issues for possible solutions.
- I can't find my issue in the FAQ.
Describe the bug
Long words that did not fit into a narrow cell are cropped instead of wrapping.
from rich.console import Console
from rich.table import Table
table = Table(width=30)
table.add_column("No")
table.add_column("Text")
table.add_row("1", "com company collections styles examples unicorn")
table.add_row("2", "com.company.collections.styles.examples.unicorn")
table.add_row("3", "wrap wrap wrap com.company.collections.styles.examples.unicorn")
console = Console()
console.print(table)Output:
┏━━━━┳━━━━━━━━━━━━━━━━━━━━━━━┓
┃ No ┃ Text ┃
┡━━━━╇━━━━━━━━━━━━━━━━━━━━━━━┩
│ 1 │ com company │
│ │ collections styles │
│ │ examples unicorn │
│ 2 │ com.company.collecti… │
│ 3 │ wrap wrap wrap │
│ │ com.company.collecti… │
└────┴───────────────────────┘
I think, we never should trim content unless instructed by a special parameter.
Desired behaviour is wrapping by actual border of the cell:
┏━━━━┳━━━━━━━━━━━━━━━━━━━━━━━┓
┃ No ┃ Text ┃
┡━━━━╇━━━━━━━━━━━━━━━━━━━━━━━┩
│ 1 │ com company │
│ │ collections styles │
│ │ examples unicorn │
│ 2 │ com.company.collectio │
| | ns.styles.examples.un |
| | icorn |
│ 3 │ wrap wrap wrap │
│ │ com.company.collectio │
| | ns.styles.examples.un |
| | icorn |
└────┴───────────────────────┘
Probably we should also add a special character like ↩ to indicate that forced wrapping occured.
┏━━━━┳━━━━━━━━━━━━━━━━━━━━━━━┓
┃ No ┃ Text ┃
┡━━━━╇━━━━━━━━━━━━━━━━━━━━━━━┩
│ 1 │ com company │
│ │ collections styles │
│ │ examples unicorn │
│ 2 │ com.company.collectio↩│
| | ns.styles.examples.un↩|
| | icorn |
│ 3 │ wrap wrap wrap │
│ │ com.company.collectio↩│
| | ns.styles.examples.un↩|
| | icorn |
└────┴───────────────────────┘