Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ind6Y-0002zk-Bg for pgsql-hackers@arkaria.postgresql.org; Sat, 04 Jan 2020 06:40:10 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1ind6W-0004jS-V3 for pgsql-hackers@arkaria.postgresql.org; Sat, 04 Jan 2020 06:40:08 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ind6W-0004jL-Lt for pgsql-hackers@lists.postgresql.org; Sat, 04 Jan 2020 06:40:08 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ind6T-0002OZ-8r for pgsql-hackers@postgresql.org; Sat, 04 Jan 2020 06:40:07 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id 0046dtQH008039; Sat, 4 Jan 2020 01:39:56 -0500 From: Tom Lane To: Peter Geoghegan cc: Robert Haas , Christoph Berg , PostgreSQL Hackers Subject: Re: pgsql: Add basic TAP tests for psql's tab-completion logic. In-reply-to: References: <20200103170226.GB32629@msg.df7cb.de> <26339.1578072930@sss.pgh.pa.us> <20200103174839.GD32629@msg.df7cb.de> <22669.1578104202@sss.pgh.pa.us> <25298.1578106280@sss.pgh.pa.us> <3055.1578115809@sss.pgh.pa.us> Comments: In-reply-to Peter Geoghegan message dated "Fri, 03 Jan 2020 21:38:25 -0800" MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0" Content-ID: <8008.1578119977.0@sss.pgh.pa.us> Date: Sat, 04 Jan 2020 01:39:55 -0500 Message-ID: <8038.1578119995@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk ------- =_aaaaaaaaaa0 Content-Type: text/plain; charset="us-ascii" Content-ID: <8008.1578119977.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Peter Geoghegan writes: > On Fri, Jan 3, 2020 at 9:30 PM Tom Lane wrote: >> BTW, it seems somewhat likely that this is less about libreadline >> than about its dependency libtinfo. On my machine that's from >> ii libtinfo6:amd64 6.1+20181013-2+deb10u2 = amd64 shared low-level terminfo library for terminal handli= ng > This seems promising. By following the same ldd + dpkg -S workflow as > before, I can see that my libtinfo is "libtinfo5:amd64". Hmm. Usually this sort of software gets more weird in newer versions, not less so ;-). Still, it's a starting point. Attached is a blind attempt to fix this by allowing escape sequence(s) instead of spaces between the words. Does this work for you? regards, tom lane ------- =_aaaaaaaaaa0 Content-Type: text/x-diff; name="allow-escape-sequences-1.patch"; charset="us-ascii" Content-ID: <8008.1578119977.2@sss.pgh.pa.us> Content-Description: allow-escape-sequences-1.patch Content-Transfer-Encoding: quoted-printable diff --git a/src/bin/psql/t/010_tab_completion.pl b/src/bin/psql/t/010_tab= _completion.pl index 96221f8..7f1797c 100644 --- a/src/bin/psql/t/010_tab_completion.pl +++ b/src/bin/psql/t/010_tab_completion.pl @@ -38,6 +38,12 @@ $node->safe_psql('postgres', my $historyfile =3D "${TestLib::log_path}/010_psql_history.txt"; $ENV{PSQL_HISTORY} =3D $historyfile; = +# Ensure that readline/libedit puts out xterm escapes, not something else= . +$ENV{TERM} =3D 'xterm'; + +# regexp to match one xterm escape sequence (CSI style only, for now) +my $escseq =3D "(\e\\[[0-9;]*[A-Za-z])"; + # fire up an interactive psql session my $in =3D ''; my $out =3D ''; @@ -101,8 +107,12 @@ check_completion( "select \\* from my\a?tab", "complete my to mytab when there are multiple choices"); = -# some versions of readline/libedit require two tabs here, some only need= one -check_completion("\t\t", "mytab123 +mytab246", +# some versions of readline/libedit require two tabs here, some only need= one. +# also, some might issue escape sequences to reposition the cursor, inste= ad +# of just printing some spaces. +check_completion( + "\t\t", + "mytab$escseq*123( +|$escseq+)mytab$escseq*246", "offer multiple table choices"); = check_completion("2\t", "246 ", ------- =_aaaaaaaaaa0--