Skip to content

Commit

Permalink
Add file argument completion to the addressbar for ice-wm/icewm#33
Browse files Browse the repository at this point in the history
  • Loading branch information
gijsbers committed May 15, 2024
1 parent 9208fa4 commit a329845
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/yinputline.cc
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,34 @@ void YInputLine::complete() {
res_count++;
if (1 <= res_count)
setText(res, res_count == 1);
else {
int i = mstr.lastIndexOf(' ');
if (i > 0 && size_t(i + 1) < mstr.length()) {
mstring sub(mstr.substring(i + 1));
YStringArray list;
if (upath::glob(sub + "*", list, "/CS") && list.nonempty()) {
if (list.getCount() == 1) {
mstring found(mstr.substring(0, i + 1) + list[0]);
setText(found, true);
} else {
int len = 0;
for (; list[0][len]; ++len) {
char ch = list[0][len];
int j = 1;
while (j < list.getCount() && ch == list[j][len])
++j;
if (j < list.getCount())
break;
}
if (len) {
mstring common(list[0], len);
mstring found(mstr.substring(0, i + 1) + common);
setText(found, false);
}
}
}
}
}
free(res);
}

Expand Down

0 comments on commit a329845

Please sign in to comment.