Do you still have this issue under WordPress 5.0?
We have not yet moved to WordPress 5.0 since we are a bit wary about the changes to the editor. We are afraid of losing access to the html editor and being stuck with the visual editor which has numerous problems. Will try once we move over though, which should be soon after trying the plug-in to keep the old editor.
The new editor still has an HTML editor, but you can also install the Classic Editor plugin to restore the old editor if desired.
We have updated to WordPress 5.1 and there has been no change in this regard.
I think it might be something that can be worked around though by paying attention. It is just odd and unexpected behaviour, especially when inserting links in existing text.
I have:
Linktext
I type this before it:
<a href="link">
And the result
<a href="link"></a>Linktext
I will just have to adjust and cut and paste the that is autoinserted instead of typing it at the end like normal.
Hm, that is odd. Any particular reason you just aren’t making links in the Visual Editor?
Do you notice any auto-save activity near the top-right just before this happens?
I’ve only noticed it so far in the HTML widgets, which don’t use autosave.
I don’t think the post editor itself uses Codemirror nor any kind of syntax highlighting, so it is not happening there.
The main reason we don’t use the visual editor is because we’ve experienced it breaks things. We also like to be able to actually see the code, making it easier to see if correct styling and attributes are used, for example, the id of a header, the style of an image or the target of an anchor tag. We have some template codes and in the HTML editor we can just copy paste blocks of code from a template to use in a new post or page, while we wouldn’t be able to paste this into the visual editor.