Filling out the template is required. Any pull request that does not include enough information to be reviewed in a timely manner may be closed at the maintainers' discretion.
All new code requires tests to ensure against regressions
Description of the Change
I assume that the point of the atom.workspace? check was to try to wait until Atom was done loading before checking for text editors. However, the workspace may be loaded before text editors are deserialized. Therefore I rely on atom.packages.hasActivatedInitialPackages, which is the same thing that would happen if atom.workspace did not exist. This means that when reloading or closing/reopening Atom with a Markdown Preview open, the preview will continue to live update as it can find its existing editor. Before, it would become orphaned and rely on the backup file system events instead (due to atom.workspace.getTextEditors() being an empty array on startup).
Alternate Designs
Relying on package activation seems a bit weird. However, there doesn't seem to be a way to get whether the workspace has fully loaded or not, so this seems like a good alternative.
Benefits
Less cases of unnecessary preview orphanage.
Possible Drawbacks
None.
Applicable Issues
N/A
I wasn't able to test for this because I had to globally spy on atom.packages.hasActivatedInitialPackages, and also because the only way to truly test this would be to simulate an entire Atom restart.
Requirements
Description of the Change
I assume that the point of the
atom.workspace?
check was to try to wait until Atom was done loading before checking for text editors. However, the workspace may be loaded before text editors are deserialized. Therefore I rely onatom.packages.hasActivatedInitialPackages
, which is the same thing that would happen ifatom.workspace
did not exist. This means that when reloading or closing/reopening Atom with a Markdown Preview open, the preview will continue to live update as it can find its existing editor. Before, it would become orphaned and rely on the backup file system events instead (due toatom.workspace.getTextEditors()
being an empty array on startup).Alternate Designs
Relying on package activation seems a bit weird. However, there doesn't seem to be a way to get whether the workspace has fully loaded or not, so this seems like a good alternative.
Benefits
Less cases of unnecessary preview orphanage.
Possible Drawbacks
None.
Applicable Issues
N/A
I wasn't able to test for this because I had to globally spy on
atom.packages.hasActivatedInitialPackages
, and also because the only way to truly test this would be to simulate an entire Atom restart.