                         state rdebug-window-configuration-state)
   (when (not (eq state rdebug-window-configuration-state))
     ;; Save the previous state.
-    (cond ((eq rdebug-window-configuration-state 'debugger)
+    (cond ((not (eq rdebug-window-configuration-state 'original))
            (setq rdebug-debugger-window-configuration
                  (current-window-configuration)))
           ((eq rdebug-window-configuration-state 'original)

    (unless dont-restore
      ;; Switch to the saved state,
      (cond
       ((eq state 'debugger)
        (if rdebug-debugger-window-configuration
            (set-window-configuration rdebug-debugger-window-configuration)))
       ((eq state 'original)



(defun rdebug--setup-secondary-window-help-buffer (buf comint-buffer)
  (rdebug-debug-enter "rdebug--setup-secondary-window-help-buffer"
    (with-current-buffer buf
      (rdebug-secondary-window-help-mode)
      (set (make-local-variable 'gud-comint-buffer) comint-buffer)
