Fix :s on element under the cursor

Broken by changes after removing trailing slash.  Used pointer to
already freed memory.  The order of actions was wrong, shouldn't
update filename that early.
Merge branch 'fix-substitute-file-under-cursor'

Fix :s on element under the cursor

Broken by changes after removing trailing slash.  Used pointer to
already freed memory.  The order of actions was wrong, shouldn't
update filename that early.