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

Commitb4771d7

Browse files
committed
Don't treat complete_from_const as equivalent to complete_from_list.
Commit4f3b38f supposed that complete_from_const() is equivalent tothe one-element-list case of complete_from_list(), but that's notreally true at all. complete_from_const() supposes that the completionis certain enough to justify wiping out whatever the user typed, whilecomplete_from_list() will only provide completions that match theword-so-far.In practice, given the lame parsing technology used by tab-complete.c,it's fairly hard to believe that we're *ever* certain enough abouta completion to justify auto-correcting user input that doesn't match.Hence, remove the inappropriate unification of the two cases.As things now stand, complete_from_const() is used only for thesituation where we have no matches and we need to keep readlinefrom applying its default complete-with-file-names behavior.This (mis?) behavior actually exists much further back, butI'm hesitant to change it in released branches. It's not toolate for v12, though, especially seeing that the aforesaidcommit is new in v12.Per gripe from Ken Tanzer.Discussion:https://postgr.es/m/CAD3a31XpXzrZA9TT3BqLSHghdTK+=cXjNCE+oL2Zn4+oWoc=qA@mail.gmail.com
1 parent0ec3e13 commitb4771d7

File tree

1 file changed

+29
-15
lines changed

1 file changed

+29
-15
lines changed

‎src/bin/psql/tab-complete.c

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -205,19 +205,22 @@ do { \
205205
matches = completion_matches(text, complete_from_versioned_schema_query); \
206206
} while (0)
207207

208+
/*
209+
* Caution: COMPLETE_WITH_CONST is not for general-purpose use; you probably
210+
* want COMPLETE_WITH() with one element, instead.
211+
*/
212+
#defineCOMPLETE_WITH_CONST(cs,con) \
213+
do { \
214+
completion_case_sensitive = (cs); \
215+
completion_charp = (con); \
216+
matches = completion_matches(text, complete_from_const); \
217+
} while (0)
218+
208219
#defineCOMPLETE_WITH_LIST_INT(cs,list) \
209220
do { \
210221
completion_case_sensitive = (cs); \
211-
if (!(list)[1]) \
212-
{ \
213-
completion_charp = (list)[0]; \
214-
matches = completion_matches(text, complete_from_const); \
215-
} \
216-
else \
217-
{ \
218-
completion_charpp = (list); \
219-
matches = completion_matches(text, complete_from_list); \
220-
} \
222+
completion_charpp = (list); \
223+
matches = completion_matches(text, complete_from_list); \
221224
} while (0)
222225

223226
#defineCOMPLETE_WITH_LIST(list) COMPLETE_WITH_LIST_INT(false, list)
@@ -3758,7 +3761,7 @@ psql_completion(const char *text, int start, int end)
37583761
*/
37593762
if (matches==NULL)
37603763
{
3761-
COMPLETE_WITH("");
3764+
COMPLETE_WITH_CONST(true,"");
37623765
#ifdefHAVE_RL_COMPLETION_APPEND_CHARACTER
37633766
rl_completion_append_character='\0';
37643767
#endif
@@ -4188,10 +4191,21 @@ complete_from_list(const char *text, int state)
41884191

41894192
/*
41904193
* This function returns one fixed string the first time even if it doesn't
4191-
* match what's there, and nothing the second time. This should be used if
4192-
* there is only one possibility that can appear at a certain spot, so
4193-
* misspellings will be overwritten. The string to be passed must be in
4194-
* completion_charp.
4194+
* match what's there, and nothing the second time. The string
4195+
* to be used must be in completion_charp.
4196+
*
4197+
* If the given string is "", this has the effect of preventing readline
4198+
* from doing any completion. (Without this, readline tries to do filename
4199+
* completion which is seldom the right thing.)
4200+
*
4201+
* If the given string is not empty, readline will replace whatever the
4202+
* user typed with that string. This behavior might be useful if it's
4203+
* completely certain that we know what must appear at a certain spot,
4204+
* so that it's okay to overwrite misspellings. In practice, given the
4205+
* relatively lame parsing technology used in this file, the level of
4206+
* certainty is seldom that high, so that you probably don't want to
4207+
* use this. Use complete_from_list with a one-element list instead;
4208+
* that won't try to auto-correct "misspellings".
41954209
*/
41964210
staticchar*
41974211
complete_from_const(constchar*text,intstate)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp