Backport of #8725 Fix so `@edit` works on windows with the default editor.

This is a backport of #8725.
@nalimilan would you check it works as you suggested in #8725?