From 70ec64e76200bcc311c1671bff3f89672f8842ec Mon Sep 17 00:00:00 2001
From: Kyotaro Horiguchi <horiguchi.kyotaro@lab.ntt.co.jp>
Date: Mon, 28 Nov 2016 16:19:46 +0900
Subject: [PATCH 10/17] Simplify completion for CLUSTER VERBOSE.

Simplify completion for CLUSTER command by removing VERBOSE.
---
 src/bin/psql/tab-complete.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c
index 44d4eb6..8c6687c 100644
--- a/src/bin/psql/tab-complete.c
+++ b/src/bin/psql/tab-complete.c
@@ -1704,17 +1704,16 @@ psql_completion_internal(const char *text, char **previous_words,
 	if (Matches1("CLUSTER"))
 		COMPLETE_WITH_SCHEMA_QUERY_KW(Query_for_list_of_tm,
 									  ADDLIST1("VERBOSE"));
-	if (Matches2("CLUSTER", "VERBOSE"))
+	/* Remove VERBOSE for further completion */
+	HeadMatchAndRemove2(2, 1, "CLUSTER", "VERBOSE");
+
+	if (Matches1("CLUSTER"))
 		COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tm);
 	/* If we have CLUSTER <sth>, then add "USING" */
-	if (Matches2("CLUSTER", MatchAnyExcept("VERBOSE|ON")))
-		COMPLETE_WITH_CONST("USING");
-	/* If we have CLUSTER VERBOSE <sth>, then add "USING" */
-	if (Matches3("CLUSTER", "VERBOSE", MatchAny))
+	if (Matches2("CLUSTER", MatchAny))
 		COMPLETE_WITH_CONST("USING");
 	/* If we have CLUSTER <sth> USING, then add the index as well */
-	if (Matches3("CLUSTER", MatchAny, "USING") ||
-			 Matches4("CLUSTER", "VERBOSE", MatchAny, "USING"))
+	if (Matches3("CLUSTER", MatchAny, "USING"))
 	{
 		completion_info_charp = prev2_wd;
 		COMPLETE_WITH_QUERY(Query_for_index_of_table);
-- 
2.9.2

