xaizek / hstr (License: Apachev2) (since 2018-12-07)
Bash and Zsh shell history suggest box - easily view, navigate, search and manage your command history.
Commit 0e564239a88347788296bfd1afbf41a6d7ba0c58

Fixed #14 by removing hash set that's no longer neede.
Author: Martin Dvorak
Author date (UTC): 2013-12-15 13:18
Committer name: Martin Dvorak
Committer date (UTC): 2013-12-15 13:18
Parent(s): 1f2ee46e39225e2505810d7f958ba8d17628a5f0
Signing key:
Tree: 9bbdbad6578f61d255b32a484cad0a306450faf7
File Lines added Lines deleted
src/hstr.c 5 13
File src/hstr.c changed (mode: 100644) (index ebb657b..51b6058)
... ... unsigned make_selection(char *prefix, HistoryItems *history, int maxSelectionCou
109 109 alloc_selection(sizeof(char*) * maxSelectionCount); // TODO realloc alloc_selection(sizeof(char*) * maxSelectionCount); // TODO realloc
110 110 unsigned i, selectionCount=0; unsigned i, selectionCount=0;
111 111
112 HashSet set;
113 hashset_init(&set);
114
115 112 for(i=0; i<history->count && selectionCount<maxSelectionCount; i++) { for(i=0; i<history->count && selectionCount<maxSelectionCount; i++) {
116 if(history->items[i]!=NULL && !hashset_contains(&set, history->items[i])) {
113 if(history->items[i]) {
117 114 if(prefix==NULL) { if(prefix==NULL) {
118 115 selection[selectionCount++]=history->items[i]; selection[selectionCount++]=history->items[i];
119 hashset_add(&set, history->items[i]);
120 116 } else { } else {
121 117 if(history->items[i]==strstr(history->items[i], prefix)) { if(history->items[i]==strstr(history->items[i], prefix)) {
122 118 selection[selectionCount++]=history->items[i]; selection[selectionCount++]=history->items[i];
123 hashset_add(&set, history->items[i]);
124 119 } }
125 120 } }
126 121 } }
127 122 } }
128 123
129 if(prefix!=NULL && selectionCount<maxSelectionCount) {
124 if(prefix && selectionCount<maxSelectionCount) {
130 125 for(i=0; i<history->count && selectionCount<maxSelectionCount; i++) { for(i=0; i<history->count && selectionCount<maxSelectionCount; i++) {
131 if(!hashset_contains(&set, history->items[i])) {
132 char *substring = strstr(history->items[i], prefix);
133 if (substring != NULL && substring!=history->items[i]) {
134 selection[selectionCount++]=history->items[i];
135 hashset_add(&set, history->items[i]);
136 }
126 char *substring = strstr(history->items[i], prefix);
127 if (substring != NULL && substring!=history->items[i]) {
128 selection[selectionCount++]=history->items[i];
137 129 } }
138 130 } }
139 131 } }
Hints

Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://code.reversed.top/user/xaizek/hstr

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@code.reversed.top/user/xaizek/hstr

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a pull request:
... clone the repository ...
... make some changes and some commits ...
git push origin master