Index: theme-editor.php
===================================================================
--- theme-editor.php	(revision 13795)
+++ theme-editor.php	(working copy)
@@ -31,7 +31,7 @@
 	wp_die(__('The requested theme does not exist.'));
 
 $allowed_files = array_merge($themes[$theme]['Stylesheet Files'], $themes[$theme]['Template Files']);
-
+$requestedfile = $file;
 if (empty($file)) {
 	$file = $allowed_files[0];
 } else {
@@ -61,12 +61,12 @@
 		if ($f !== FALSE) {
 			fwrite($f, $newcontent);
 			fclose($f);
-			$location = "theme-editor.php?file=$file&theme=$theme&a=te&scrollto=$scrollto";
+			$location = "theme-editor.php?file=$requestedfile&theme=$theme&a=te&scrollto=$scrollto&dir=$dir";
 		} else {
-			$location = "theme-editor.php?file=$file&theme=$theme&scrollto=$scrollto";
+			$location = "theme-editor.php?file=$requestedfile&theme=$theme&scrollto=$scrollto&dir=$dir";
 		}
 	} else {
-		$location = "theme-editor.php?file=$file&theme=$theme&scrollto=$scrollto";
+		$location = "theme-editor.php?file=$requestedfile&theme=$theme&scrollto=$scrollto&dir=$dir";
 	}
 
 	$location = wp_kses_no_null($location);
@@ -197,7 +197,8 @@
 	<?php wp_nonce_field('edit-theme_' . $file . $theme) ?>
 		 <div><textarea cols="70" rows="25" name="newcontent" id="newcontent" tabindex="1" class="codepress <?php echo $codepress_lang ?>"><?php echo $content ?></textarea>
 		 <input type="hidden" name="action" value="update" />
-		 <input type="hidden" name="file" value="<?php echo esc_attr($file) ?>" />
+		 <input type="hidden" name="file" value="<?php echo esc_attr($requestedfile) ?>" />
+		 <input type="hidden" name="dir" value="<?php echo esc_attr($dir) ?>" />
 		 <input type="hidden" name="theme" value="<?php echo esc_attr($theme) ?>" />
 		 <input type="hidden" name="scrollto" id="scrollto" value="<?php echo $scrollto; ?>" />
 		 </div>
