diff --git a/wp-admin/theme-editor.php b/wp-admin/theme-editor.php
index 887eb4c06b..979ac46329 100644
--- a/wp-admin/theme-editor.php
+++ b/wp-admin/theme-editor.php
@@ -135,12 +135,22 @@ if ($allowed_files) :
($template_show)" : "$description";
$filedesc = ( $template_file == $file ) ? "$description ($template_show)" : $filedesc;
- $template_mapping[ $description ] = array( $template_file, $filedesc );
+
+ // If we have two files of the same name prefer the one in the Template Directory
+ // This means that we display the correct files for child themes which overload Templates as well as Styles
+ if( array_key_exists($description, $template_mapping ) ) {
+ if ( false !== strpos( $template_file, $template_dir ) ) {
+ $template_mapping[ $description ] = array( $template_file, $filedesc );
+ }
+ } else {
+ $template_mapping[ $description ] = array( $template_file, $filedesc );
+ }
}
ksort( $template_mapping );
while ( list( $template_sorted_key, list( $template_file, $filedesc ) ) = each( $template_mapping ) ) :