Move cmd editing to outer let.

This prevents buffer creation if user cancels during editing.