completely new completion logic
fix escaping in sed expression
simplify file path escaping
code cleanup
performance improvement: skip case statement if prev is null