From 1aa9986d144d11ad57b127e460a348e05e687d85 Mon Sep 17 00:00:00 2001 From: tanghy Date: Wed, 15 Sep 2021 23:37:34 +0900 Subject: [PATCH v3] support tab-completion for CONNECTION string with equal sign diff --git a/src/bin/psql/t/010_tab_completion.pl b/src/bin/psql/t/010_tab_completion.pl index 8695d22545..5537006b11 100644 --- a/src/bin/psql/t/010_tab_completion.pl +++ b/src/bin/psql/t/010_tab_completion.pl @@ -194,6 +194,14 @@ check_completion( clear_query(); +# check tab-completion for CONNECTION string with equal sign. +check_completion( + "CREATE SUBSCRIPTION my_sub CONNECTION 'host=localhost port=5432 dbname=postgres' \t", + qr|PUBLICATION|, + "tab-completion for CONNECTION string with equal sign"); + +clear_query(); + # COPY requires quoting # note: broken versions of libedit want to backslash the closing quote; # not much we can do about that diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c index 5cd5838668..ec42784fef 100644 --- a/src/bin/psql/tab-complete.c +++ b/src/bin/psql/tab-complete.c @@ -2810,8 +2810,11 @@ psql_completion(const char *text, int start, int end) /* CREATE SUBSCRIPTION */ else if (Matches("CREATE", "SUBSCRIPTION", MatchAny)) COMPLETE_WITH("CONNECTION"); - else if (Matches("CREATE", "SUBSCRIPTION", MatchAny, "CONNECTION", MatchAny)) - COMPLETE_WITH("PUBLICATION"); + else if ((HeadMatches("CREATE", "SUBSCRIPTION", MatchAny, "CONNECTION", MatchAny))) + { + if (ends_with(prev_wd, '\'')) + COMPLETE_WITH("PUBLICATION"); + } else if (Matches("CREATE", "SUBSCRIPTION", MatchAny, "CONNECTION", MatchAny, "PUBLICATION")) { -- 2.33.0.windows.2