Auto-complete fixes

Fixed auto-completion for the cases when cursor is in the middle of the
text. Also filter auto-completion suggestions to remove empty strings
provided by node.js repl.