mirror of
https://github.com/postgres/postgres.git
synced 2025-04-21 12:05:57 +03:00
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
This commit is contained in:
parent
605062227f
commit
927332b95e
@ -413,6 +413,14 @@ check_completion(
|
|||||||
|
|
||||||
clear_query();
|
clear_query();
|
||||||
|
|
||||||
|
# check completion for psql variable test
|
||||||
|
check_completion(
|
||||||
|
"\\echo :{?VERB\t",
|
||||||
|
qr/:\{\?VERBOSITY} /,
|
||||||
|
"complete a psql variable test");
|
||||||
|
|
||||||
|
clear_query();
|
||||||
|
|
||||||
# check no-completions code path
|
# check no-completions code path
|
||||||
check_completion("blarg \t\t", qr//, "check completion failure path");
|
check_completion("blarg \t\t", qr//, "check completion failure path");
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* word break characters */
|
/* word break characters */
|
||||||
#define WORD_BREAKS "\t\n@><=;|&{() "
|
#define WORD_BREAKS "\t\n@><=;|&() "
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Since readline doesn't let us pass any state through to the tab completion
|
* 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)
|
|||||||
matches = complete_from_variables(text, ":'", "'", true);
|
matches = complete_from_variables(text, ":'", "'", true);
|
||||||
else if (text[1] == '"')
|
else if (text[1] == '"')
|
||||||
matches = complete_from_variables(text, ":\"", "\"", true);
|
matches = complete_from_variables(text, ":\"", "\"", true);
|
||||||
|
else if (text[1] == '{' && text[2] == '?')
|
||||||
|
matches = complete_from_variables(text, ":{?", "}", true);
|
||||||
else
|
else
|
||||||
matches = complete_from_variables(text, ":", "", true);
|
matches = complete_from_variables(text, ":", "", true);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user