psql patch: tab-complete :variables also at buffer start
От | Christoph Berg |
---|---|
Тема | psql patch: tab-complete :variables also at buffer start |
Дата | |
Msg-id | 20110210103733.GB3287@msgid.df7cb.de обсуждение исходный текст |
Ответы |
Re: psql patch: tab-complete :variables also at buffer start
|
Список | pgsql-hackers |
Currently, tab-completing :variable names in psql does not work at the beginning of the line. Fix this by moving the code block before the "empty buffer" case. (I have several "sql macros" in my .psqlrc like :relsize that prints table sizes in a nicely formatted way, being able to type :<tab> would be very welcome.) diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c index 1c9623d..a540912 100644 *** a/src/bin/psql/tab-complete.c --- b/src/bin/psql/tab-complete.c *************** psql_completion(char *text, int start, i *** 761,766 **** --- 761,777 ---- if (text[0] == '\\') COMPLETE_WITH_LIST(backslash_commands); + /* Variable interpolation */ + else if (text[0] == ':' && text[1] != ':') + { + if (text[1] == '\'') + matches = complete_from_variables(text, ":'", "'"); + else if (text[1] == '"') + matches = complete_from_variables(text, ":\"", "\""); + else + matches = complete_from_variables(text, ":", ""); + } + /* If no previous word, suggest one of the basic sql commands */ else if (!prev_wd) COMPLETE_WITH_LIST(sql_commands); *************** psql_completion(char *text, int start, i *** 2767,2783 **** ) matches = completion_matches(text, filename_completion_function); - /* Variable interpolation */ - else if (text[0] == ':' && text[1] != ':') - { - if (text[1] == '\'') - matches = complete_from_variables(text, ":'", "'"); - else if (text[1] == '"') - matches = complete_from_variables(text, ":\"", "\""); - else - matches = complete_from_variables(text, ":", ""); - } - /* * Finally, we look through the list of "things", such as TABLE, INDEX and * check if that was the previousword. If so, execute the query to get a --- 2778,2783 ---- Christoph -- cb@df7cb.de | http://www.df7cb.de/
В списке pgsql-hackers по дате отправления: