inducer / pudb

Full-screen console debugger for Python
https://documen.tician.de/pudb/
Other
3k stars 230 forks source link

Clean up some render issues with long vars/values in the var_view #424

Closed mvanderkamp closed 3 years ago

mvanderkamp commented 3 years ago

This PR just deals with some pretty minor things in the way the var_view renders variables with long names and/or values.

If you have a really long variable/value combo in the var view and you don't wrap, the value is printed on a subsequent line, e.g.

| | .my_long_named_attribute
| |   [0, 1, 2, 3, 4, 5]

If you were to wrap the same variable it might be rendered as:

| | .my_long_named_attribute: [0, 1,
  | | 2, 3, 4, 5]

This PR normalizes the two by making the non-wrapped one look like this: (note the ":" on the first line)

| | .my_long_named_attribute:
| |   [0, 1, 2, 3, 4, 5]

And the wrapped one look like this: (note the spaces on the second line now come after the prefix)

| | .my_long_named_attribute: [0, 1,
| |   2, 3, 4, 5]

There's also a tweak to make sure that when not wrapping, we'll only use two lines for a variable if we actually don't have enough space to show it in one.

mvanderkamp commented 3 years ago

I did a bit of refactoring to unpack the size tuple earlier, which seems more clear to me, and added documentation.

inducer commented 3 years ago

LGTM, thanks!