VisualEditor runs the VisualEditorHooks::onSkinTemplateNavigation() hook to configure the "edit" and "edit source" links. In case the hook does not run, VE also uses JS to set up those links. The issue involves the JS if/else block starting here:
This block overwrites the contents of the "edit source" link even if the hook already configured the link correctly. This causes formatting issues in third-party skins. For example, in the Refreshed skin, page tool links contain a span and an inline svg. When VE's JS overwrites the "edit source" link, it removes the link's span and svg elements, breaking the link's formatting.
The fix should be simple. Just move that if/else block from earlier into the if statement that starts here:
That way, the JS will only overwrite the "edit source" link text if the hook didn't run.