Fix completion when FS operations are async.

(auto-select first item)
improve code for filename completion (abstract the local filesystem implementation)