forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitd854118
committed
Teach psql's tab completion to consider the entire input string.
Up to now, the tab completion logic has only examined the last few wordsof the current input line; "last few" being originally as few as fourwords, but lately up to nine words. Furthermore, it only looked at whatlibreadline considers the current line of input, which made it rathermyopic if you split your command across lines. This was tolerable,sort of, so long as the match patterns were only designed to consider thelast few words of input; but with the recent addition of HeadMatches()and Matches() matching rules, we really have to do better if we wantthose to behave sanely.Hence, change the code to break the entire line down into words, and toinclude any previous lines in the command buffer along with the activereadline input buffer.This will be a little bit slower than the previous coding, but somemeasurements say that even a query of several thousand characters can beparsed in a hundred or so microseconds on modern machines; so it's reallynot going to be significant for interactive tab completion. To reducethe cost some, I arranged to avoid the per-word malloc calls that usedto occur: all the words are now kept in one malloc'd buffer.1 parent69e7c44 commitd854118
File tree
5 files changed
+150
-95
lines changed- src/bin/psql
5 files changed
+150
-95
lines changedLines changed: 12 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
53 | 53 |
| |
54 | 54 |
| |
55 | 55 |
| |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
56 | 61 |
| |
57 | 62 |
| |
58 | 63 |
| |
59 | 64 |
| |
60 | 65 |
| |
61 |
| - | |
| 66 | + | |
62 | 67 |
| |
63 | 68 |
| |
64 | 69 |
| |
| |||
76 | 81 |
| |
77 | 82 |
| |
78 | 83 |
| |
| 84 | + | |
| 85 | + | |
| 86 | + | |
79 | 87 |
| |
80 | 88 |
| |
81 | 89 |
| |
| |||
85 | 93 |
| |
86 | 94 |
| |
87 | 95 |
| |
| 96 | + | |
| 97 | + | |
| 98 | + | |
88 | 99 |
| |
89 | 100 |
| |
90 | 101 |
| |
|
Lines changed: 7 additions & 7 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
12 | 12 |
| |
13 | 13 |
| |
14 | 14 |
| |
15 |
| - | |
| 15 | + | |
16 | 16 |
| |
17 | 17 |
| |
18 | 18 |
| |
| |||
38 | 38 |
| |
39 | 39 |
| |
40 | 40 |
| |
41 |
| - | |
42 |
| - | |
| 41 | + | |
| 42 | + | |
43 | 43 |
| |
44 |
| - | |
| 44 | + | |
45 | 45 |
| |
46 |
| - | |
| 46 | + | |
47 | 47 |
| |
48 |
| - | |
49 |
| - | |
| 48 | + | |
| 49 | + | |
50 | 50 |
| |
51 | 51 |
|
Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
133 | 133 |
| |
134 | 134 |
| |
135 | 135 |
| |
136 |
| - | |
| 136 | + | |
137 | 137 |
| |
138 | 138 |
| |
139 | 139 |
| |
|
0 commit comments
Comments
(0)