diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php b/core/modules/views/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php
index 5cae913..936fbcd 100644
--- a/core/modules/views/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php
+++ b/core/modules/views/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php
@@ -1750,74 +1750,8 @@ public function buildOptionsForm(&$form, &$form_state) {
         );
         break;
       case 'analyze-theme':
+        $this->getThemeInformation();
         $form['#title'] .= t('Theming information');
-        if ($theme = \Drupal::request()->request->get('theme')) {
-          $this->theme = $theme;
-        }
-        elseif (empty($this->theme)) {
-          $this->theme = \Drupal::config('system.theme')->get('default');
-        }
-
-        if (isset($GLOBALS['theme']) && $GLOBALS['theme'] == $this->theme) {
-          $this->theme_registry = theme_get_registry();
-          $theme_engine = $GLOBALS['theme_engine'];
-        }
-        else {
-          $themes = list_themes();
-          $theme = $themes[$this->theme];
-
-          // Find all our ancestor themes and put them in an array.
-          $base_theme = array();
-          $ancestor = $this->theme;
-          while ($ancestor && isset($themes[$ancestor]->base_theme)) {
-            $ancestor = $themes[$ancestor]->base_theme;
-            $base_theme[] = $themes[$ancestor];
-          }
-
-          // The base themes should be initialized in the right order.
-          $base_theme = array_reverse($base_theme);
-
-          // This code is copied directly from _drupal_theme_initialize()
-          $theme_engine = NULL;
-
-          // Initialize the theme.
-          if (isset($theme->engine)) {
-            // Include the engine.
-            include_once DRUPAL_ROOT . '/' . $theme->owner;
-
-            $theme_engine = $theme->engine;
-            if (function_exists($theme_engine . '_init')) {
-              foreach ($base_theme as $base) {
-                call_user_func($theme_engine . '_init', $base);
-              }
-              call_user_func($theme_engine . '_init', $theme);
-            }
-          }
-          else {
-            // include non-engine theme files
-            foreach ($base_theme as $base) {
-              // Include the theme file or the engine.
-              if (!empty($base->owner)) {
-                include_once DRUPAL_ROOT . '/' . $base->owner;
-              }
-            }
-            // and our theme gets one too.
-            if (!empty($theme->owner)) {
-              include_once DRUPAL_ROOT . '/' . $theme->owner;
-            }
-          }
-          $this->theme_registry = _theme_load_registry($theme, $base_theme, $theme_engine);
-        }
-
-        // If there's a theme engine involved, we also need to know its extension
-        // so we can give the proper filename.
-        $this->theme_extension = '.html.twig';
-        if (isset($theme_engine)) {
-          $extension_function = $theme_engine . '_extension';
-          if (function_exists($extension_function)) {
-            $this->theme_extension = $extension_function();
-          }
-        }
 
         $funcs = array();
         // Get theme functions for the display. Note that some displays may
@@ -1905,6 +1839,7 @@ public function buildOptionsForm(&$form, &$form_state) {
         $form_state['ok_button'] = TRUE;
         break;
       case 'analyze-theme-display':
+        $this->getThemeInformation();
         $form['#title'] .= t('Theming information (display)');
         $output = '<p>' . t('Back to !info.', array('!info' => $this->optionLink(t('theming information'), 'analyze-theme'))) . '</p>';
 
@@ -1913,7 +1848,7 @@ public function buildOptionsForm(&$form, &$form_state) {
         }
         else {
           $output .= '<p>' . t('This is the default theme template used for this display.') . '</p>';
-          $output .= '<pre>' . check_plain(file_get_contents('./' . $this->definition['theme_path'] . '/' . strtr($this->definition['theme'], '_', '-') . '.tpl.php')) . '</pre>';
+          $output .= '<pre>' . check_plain(file_get_contents('./' . $this->definition['theme_path'] . '/' . strtr($this->definition['theme'], '_', '-') . $this->theme_extension)) . '</pre>';
         }
 
         $form['analysis'] = array(
@@ -1923,6 +1858,7 @@ public function buildOptionsForm(&$form, &$form_state) {
         $form_state['ok_button'] = TRUE;
         break;
       case 'analyze-theme-style':
+        $this->getThemeInformation();
         $form['#title'] .= t('Theming information (style)');
         $output = '<p>' . t('Back to !info.', array('!info' => $this->optionLink(t('theming information'), 'analyze-theme'))) . '</p>';
 
@@ -1933,7 +1869,7 @@ public function buildOptionsForm(&$form, &$form_state) {
         }
         else {
           $output .= '<p>' . t('This is the default theme template used for this style.') . '</p>';
-          $output .= '<pre>' . check_plain(file_get_contents('./' . $plugin->definition['theme_path'] . '/' . strtr($plugin->definition['theme'], '_', '-') . '.tpl.php')) . '</pre>';
+          $output .= '<pre>' . check_plain(file_get_contents('./' . $plugin->definition['theme_path'] . '/' . strtr($plugin->definition['theme'], '_', '-') . $this->theme_extension)) . '</pre>';
         }
 
         $form['analysis'] = array(
@@ -1943,6 +1879,7 @@ public function buildOptionsForm(&$form, &$form_state) {
         $form_state['ok_button'] = TRUE;
         break;
       case 'analyze-theme-row':
+        $this->getThemeInformation();
         $form['#title'] .= t('Theming information (row style)');
         $output = '<p>' . t('Back to !info.', array('!info' => $this->optionLink(t('theming information'), 'analyze-theme'))) . '</p>';
 
@@ -1953,7 +1890,7 @@ public function buildOptionsForm(&$form, &$form_state) {
         }
         else {
           $output .= '<p>' . t('This is the default theme template used for this row style.') . '</p>';
-          $output .= '<pre>' . check_plain(file_get_contents('./' . $plugin->definition['theme_path'] . '/' . strtr($plugin->definition['theme'], '_', '-') . '.tpl.php')) . '</pre>';
+          $output .= '<pre>' . check_plain(file_get_contents('./' . $plugin->definition['theme_path'] . '/' . strtr($plugin->definition['theme'], '_', '-') . $this->theme_extension)) . '</pre>';
         }
 
         $form['analysis'] = array(
@@ -1963,6 +1900,7 @@ public function buildOptionsForm(&$form, &$form_state) {
         $form_state['ok_button'] = TRUE;
         break;
       case 'analyze-theme-field':
+        $this->getThemeInformation();
         $form['#title'] .= t('Theming information (row style)');
         $output = '<p>' . t('Back to !info.', array('!info' => $this->optionLink(t('theming information'), 'analyze-theme'))) . '</p>';
 
@@ -1970,7 +1908,7 @@ public function buildOptionsForm(&$form, &$form_state) {
 
         // Field templates aren't registered the normal way...and they're always
         // this one, anyhow.
-        $output .= '<pre>' . check_plain(file_get_contents(drupal_get_path('module', 'views') . '/templates/views-view-field.tpl.php')) . '</pre>';
+        $output .= '<pre>' . check_plain(file_get_contents(drupal_get_path('module', 'views') . '/templates/views-view-field' . $this->theme_extension)) . '</pre>';
 
         $form['analysis'] = array(
           '#markup' => '<div class="form-item">' . $output . '</div>',
@@ -2852,6 +2790,79 @@ protected function mergeHandler($type) {
     $this->setOption($types[$type]['plural'], $options);
   }
 
+  /**
+   * Gets information about the current theme or a specific theme.
+   */
+  protected function getThemeInformation() {
+    if ($theme = \Drupal::request()->request->get('theme')) {
+      $this->theme = $theme;
+    }
+    elseif (empty($this->theme)) {
+      $this->theme = \Drupal::config('system.theme')->get('default');
+    }
+
+    if (isset($GLOBALS['theme']) && $GLOBALS['theme'] == $this->theme) {
+      $this->theme_registry = theme_get_registry();
+      $theme_engine = $GLOBALS['theme_engine'];
+    }
+    else {
+      $themes = list_themes();
+      $theme = $themes[$this->theme];
+
+      // Find all our ancestor themes and put them in an array.
+      $base_theme = array();
+      $ancestor = $this->theme;
+      while ($ancestor && isset($themes[$ancestor]->base_theme)) {
+        $ancestor = $themes[$ancestor]->base_theme;
+        $base_theme[] = $themes[$ancestor];
+      }
+
+      // The base themes should be initialized in the right order.
+      $base_theme = array_reverse($base_theme);
+
+      // This code is copied directly from _drupal_theme_initialize()
+      $theme_engine = NULL;
+
+      // Initialize the theme.
+      if (isset($theme->engine)) {
+        // Include the engine.
+        include_once DRUPAL_ROOT . '/' . $theme->owner;
+
+        $theme_engine = $theme->engine;
+        if (function_exists($theme_engine . '_init')) {
+          foreach ($base_theme as $base) {
+            call_user_func($theme_engine . '_init', $base);
+          }
+          call_user_func($theme_engine . '_init', $theme);
+        }
+      }
+      else {
+        // include non-engine theme files
+        foreach ($base_theme as $base) {
+          // Include the theme file or the engine.
+          if (!empty($base->owner)) {
+            include_once DRUPAL_ROOT . '/' . $base->owner;
+          }
+        }
+        // and our theme gets one too.
+        if (!empty($theme->owner)) {
+          include_once DRUPAL_ROOT . '/' . $theme->owner;
+        }
+      }
+      $this->theme_registry = _theme_load_registry($theme, $base_theme, $theme_engine);
+    }
+
+    // If there's a theme engine involved, we also need to know its extension
+    // so we can give the proper filename.
+    $this->theme_extension = '.html.twig';
+    if (isset($theme_engine)) {
+      $extension_function = $theme_engine . '_extension';
+      if (function_exists($extension_function)) {
+        $this->theme_extension = $extension_function();
+      }
+    }
+  }
+
 }
 
 /**
