Modified open-document to avoid generating a new doc that won't get used if the same file is opened.
If the same file is opened then the existing editor associated with the document will be selected.
Modified condition to determine when a directory has or does not have been loaded lazily already.