summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmjith Ramanujam <amjith.r@gmail.com>2021-05-06 08:12:31 -0700
committerGitHub <noreply@github.com>2021-05-06 08:12:31 -0700
commit3a95530677a892995f9de3af9043ce14285a81b8 (patch)
treec91f8257deacc249b02b600646448336129cb62b
parent26bdc4e7599d11ba3e2cef4dc8e3df3bdedbdf91 (diff)
parent2fe94c38b4e2fb3f724598b15c1dca280961a84e (diff)
Merge branch 'master' into func-pr
-rw-r--r--AUTHORS1
-rw-r--r--changelog.rst3
-rw-r--r--pgcli/main.py11
3 files changed, 11 insertions, 4 deletions
diff --git a/AUTHORS b/AUTHORS
index 8018acf6..bcfba6a3 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -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 20f61b80..4fd6fb28 100644
--- a/changelog.rst
+++ b/changelog.rst
@@ -16,7 +16,8 @@ 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)
-* Add function literals random, g;nerate_series, generate_subscripts
+* Add function literals random, generate_series, generate_subscripts
+* 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..ecf041bb 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:
@@ -1247,8 +1248,7 @@ def cli(
else:
print("Config file is now located at", config_full_path)
print(
- "Please move the existing config file ~/.pgclirc to",
- config_full_path,
+ "Please move the existing config file ~/.pgclirc to", config_full_path,
)
if list_dsn:
try:
@@ -1487,7 +1487,12 @@ 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
)