Peter Geoghegan <pg@bowt.ie> writes:
> On Fri, Jan 3, 2020 at 9:30 PM Tom Lane <tgl@sss.pgh.pa.us> 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
terminfolibrary for terminal handling
> 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
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 = "${TestLib::log_path}/010_psql_history.txt";
$ENV{PSQL_HISTORY} = $historyfile;
+# Ensure that readline/libedit puts out xterm escapes, not something else.
+$ENV{TERM} = 'xterm';
+
+# regexp to match one xterm escape sequence (CSI style only, for now)
+my $escseq = "(\e\\[[0-9;]*[A-Za-z])";
+
# fire up an interactive psql session
my $in = '';
my $out = '';
@@ -101,8 +107,12 @@ check_completion(
"select \\* from my\a?tab",
"complete my<tab> 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, instead
+# 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 ",