Rename lastSelectedEditor to lastFileSelection with bug fixes
Fixes a race condition