Improve tab completion offset stuff

This improves the robustness of helper-nipap when it is trying to find
the correct offset to start parsing arguments at.

Part of #375.