Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 927332b

Browse files
committed
psql: fix variable existence tab completion
psql has the :{?name} syntax for testing for a psql variable existence. This commit implements a tab completion for this syntax. Notably, in order to implement this we have to remove '{' from WORD_BREAKS. It appears that '{' here from the very beginning and it comes from the default value of rl_basic_word_break_characters. And :{?name} is the only psql syntax using the '{' sign. So, removing it from WORD_BREAKS shouldn't break anything. Discussion: https://postgr.es/m/CAGRrpzZU48F2oV3d8eDLr%3D4TU9xFH5Jt9ED%2BqU1%2BX91gMH68Sw%40mail.gmail.com Author: Steve Chavez Reviewed-by: Erik Wienhold
1 parent 6050622 commit 927332b

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/bin/psql/t/010_tab_completion.pl

+8
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,14 @@ sub clear_line
413413

414414
clear_query();
415415

416+
# check completion for psql variable test
417+
check_completion(
418+
"\\echo :{?VERB\t",
419+
qr/:\{\?VERBOSITY} /,
420+
"complete a psql variable test");
421+
422+
clear_query();
423+
416424
# check no-completions code path
417425
check_completion("blarg \t\t", qr//, "check completion failure path");
418426

src/bin/psql/tab-complete.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
#endif
7777

7878
/* word break characters */
79-
#define WORD_BREAKS "\t\n@><=;|&{() "
79+
#define WORD_BREAKS "\t\n@><=;|&() "
8080

8181
/*
8282
* Since readline doesn't let us pass any state through to the tab completion
@@ -1786,6 +1786,8 @@ psql_completion(const char *text, int start, int end)
17861786
matches = complete_from_variables(text, ":'", "'", true);
17871787
else if (text[1] == '"')
17881788
matches = complete_from_variables(text, ":\"", "\"", true);
1789+
else if (text[1] == '{' && text[2] == '?')
1790+
matches = complete_from_variables(text, ":{?", "}", true);
17891791
else
17901792
matches = complete_from_variables(text, ":", "", true);
17911793
}

0 commit comments

Comments
 (0)