babarot / enhancd

:rocket: A next-generation cd command with your interactive filter
2.58k stars 109 forks source link

Single results are still showing the filter #207 #220

Closed augustocdias closed 1 year ago

augustocdias commented 1 year ago

Fixes #207

Single results are still showing the filter.

Darkclainer commented 1 year ago

Hello! Your PR made me revisit problem more thoroughly and actually spot problem.

It seems that problem on line 14:

set -l count (echo "$stdin" | _enhancd_command_grep -c "")

should be

set -l count (echo -n "$stdin" | _enhancd_command_grep -c "")

The reason is actually pretty simple, but was hard to spot. Argument for this function read from the stdin with function read -z that reads everything including last newline. Then new newline added with echo if we are not using -n option (no newline). This way we always had one empty newline that caused switch never hitting first case.