complete: Don't allow wrapping a command with itself

Double-fixes #5541, by not allowing it to happen.
This commit is contained in:
Fabian Homborg 2019-01-17 09:49:50 +01:00
parent 84339d5636
commit 58b696bed1

View File

@ -1656,6 +1656,11 @@ bool complete_add_wrapper(const wcstring &command, const wcstring &new_target) {
return false;
}
// If the command and the target are the same,
// there's no point in following the wrap-chain because we'd only complete the same thing.
// TODO: This should maybe include full cycle detection.
if (command == new_target) return false;
auto locked_map = wrapper_map.acquire();
wrapper_map_t &wraps = *locked_map;
wcstring_list_t *targets = &wraps[command];