Backport of #8838 and #9143 squashed

Fixes space completion in paths in the REPL like: cd C:\\Program\ Files\\.
@tkelman merge this when you find it the timing is right.