How to exclude certain files from the plugin editor?

Ok I figured it out, there is just one filter hook in the wp-admin/plugin-editor.php that can be useful but it’s enough (otherwise one would probably need to mess with the output buffer).

if(is_admin()){
    add_filter('editable_extensions', array($this, 'my_editable_extensions'));
}    

and then

function my_editable_extensions($editable_extensions){
    if(empty($_POST['plugin']) || (!empty($_POST['plugin']) && $_POST['plugin'] !== "plugin-name/plugin-name.php"){
        return $editable_extensions;
    }else{
        return array_diff($editable_extensions, array('txt', 'html'));
    }
}

Note: wp_reset_vars() is called so the only way to know which plugin’s files are being edited is from the $_POST.