diff options
author | Amjith Ramanujam <amjith.r@gmail.com> | 2021-05-05 20:59:53 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-05 20:59:53 -0700 |
commit | 803a9d329459064cf0bffddfac29cbc95509998b (patch) | |
tree | c0012fec8626d1fa93e07e27153d19db327acf18 | |
parent | 954b8c3902b251aeb7a576e275393a2c61644286 (diff) | |
parent | 773f69ba432c995344748b427ba3902c5ee6e665 (diff) |
Merge pull request #1263 from psacawa/pr
Fix: ANSI escape codes in first line make the cli choose expanded output incorrectly...
-rw-r--r-- | AUTHORS | 1 | ||||
-rw-r--r-- | changelog.rst | 1 | ||||
-rw-r--r-- | pgcli/main.py | 3 |
3 files changed, 4 insertions, 1 deletions
@@ -117,6 +117,7 @@ Contributors: * Eero Ruohola (ruohola) * Miroslav Šedivý (eumiro) * Eric R Young (ERYoung11) + * Paweł Sacawa (psacawa) Creator: -------- diff --git a/changelog.rst b/changelog.rst index bc1ad77b..fdf0701c 100644 --- a/changelog.rst +++ b/changelog.rst @@ -16,6 +16,7 @@ Bug fixes: * Fix comments being lost in config when saving a named query. (#1240) * Fix IPython magic for ipython-sql >= 0.4.0 * Fix pager not being used when output format is set to csv. (#1238) +* Fix ANSI escape codes in first line make the cli choose expanded output incorrectly 3.1.0 ===== diff --git a/pgcli/main.py b/pgcli/main.py index e1c6fc71..05d97e73 100644 --- a/pgcli/main.py +++ b/pgcli/main.py @@ -26,6 +26,7 @@ keyring = None # keyring will be loaded later from cli_helpers.tabular_output import TabularOutputFormatter from cli_helpers.tabular_output.preprocessors import align_decimals, format_numbers +from cli_helpers.utils import strip_ansi import click try: @@ -1487,7 +1488,7 @@ def format_output(title, cur, headers, status, settings): formatted = iter(formatted.splitlines()) first_line = next(formatted) formatted = itertools.chain([first_line], formatted) - if not expanded and max_width and len(first_line) > max_width and headers: + if not expanded and max_width and len(strip_ansi(first_line)) > max_width and headers: formatted = formatter.format_output( cur, headers, format_name="vertical", column_types=None, **output_kwargs ) |