Texteditor fixes

This fixes #657 (together with PR #641) and #427 as well as a yet unreported bug when the editor is open and a text file is chosen from the search list (used to empty the editor, now just does not open the file.) not perfect but better than the current situation.

I bet using the mime type to set the syntax highlighting mode could be extended for other file types as well. But this PR fixes bugs and does not try to introduce new ones ... whoever finds the commit where I just refactor stuff will get a beer for being a good reviewer.

@DeepDiver1975 @j-ed @tomneedham @karlitschek @icewind1991 @Raydiation @bartv2 please review and :+1: