Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit927332b

Browse files
committed
psql: fix variable existence tab completion
psql has the :{?name} syntax for testing for a psql variable existence. Thiscommit implements a tab completion for this syntax. Notably, in order toimplement this we have to remove '{' from WORD_BREAKS. It appears that'{' here from the very beginning and it comes from the default value ofrl_basic_word_break_characters. And :{?name} is the only psql syntax usingthe '{' sign. So, removing it from WORD_BREAKS shouldn't break anything.Discussion:https://postgr.es/m/CAGRrpzZU48F2oV3d8eDLr%3D4TU9xFH5Jt9ED%2BqU1%2BX91gMH68Sw%40mail.gmail.comAuthor: Steve ChavezReviewed-by: Erik Wienhold
1 parent6050622 commit927332b

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

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

Lines changed: 8 additions & 0 deletions
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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
#endif
7777

7878
/* word break characters */
79-
#defineWORD_BREAKS"\t\n@><=;|&{() "
79+
#defineWORD_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
elseif (text[1]=='"')
17881788
matches=complete_from_variables(text,":\"","\"", true);
1789+
elseif (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)

[8]ページ先頭

©2009-2025 Movatter.jp