Repository: spyder-ide/spyder

Issue:
The editor menu has undock option after undock.
<!--- **PLEASE READ:** When submitting here, please ensure you've completed the following checklist and checked the boxes to confirm. Issue reports without it may be closed. Thanks! --->

## Problem Description
I like new GUI. But I found a strange behaviour.

The editor menu has undock option after undock.

![undock](https://user-images.githubusercontent.com/22970578/50393285-99e73280-0798-11e9-94e7-4cb136a063f4.gif)


### What steps reproduce the problem?

1. editor undock
2. check editor menu

## Versions
<!--- You can get this information from Help > About Spyder...
or (if Spyder won't launch) the "conda list" command
from the Anaconda Prompt/Terminal/command line. --->

* Spyder version: spyder 4.0.0dev0 (lastest commit)
* Python version: 3.6.7 
* Qt version: 5.9.7
* PyQt version: 5.9.2
* Operating System name/version: 4.19.12-1-MANJARO

### Dependencies
<!--- Please go to the menu entry Help > Dependencies,
press the Copy to clipboard button and paste below --->

```
PASTE DEPENDENCIES HERE
```



Discussion:

Resolving patch:
diff --git a/spyder/plugins/editor/plugin.py b/spyder/plugins/editor/plugin.py
--- a/spyder/plugins/editor/plugin.py
+++ b/spyder/plugins/editor/plugin.py
@@ -1593,10 +1593,10 @@ def setup_other_windows(self):
 
     def switch_to_plugin(self):
         """
-        Reimplemented method to desactivate shortcut when
+        Reimplemented method to deactivate shortcut when
         opening a new window.
         """
-        if not self.editorwindows or self.dockwidget.isVisible():
+        if not self.editorwindows:
             super(Editor, self).switch_to_plugin()
 
     def create_new_window(self):
diff --git a/spyder/plugins/editor/widgets/editor.py b/spyder/plugins/editor/widgets/editor.py
--- a/spyder/plugins/editor/widgets/editor.py
+++ b/spyder/plugins/editor/widgets/editor.py
@@ -1344,19 +1344,22 @@ def __get_split_actions(self):
         # Regular actions
         actions = [MENU_SEPARATOR, self.versplit_action,
                    self.horsplit_action, self.close_action]
-        if plugin is not None:
-            actions += [MENU_SEPARATOR, self.new_window_action,
-                        plugin.undock_action, plugin.close_plugin_action]
 
-        # Actions when the stack is part of an undocked window
         if self.new_window:
-            actions = [MENU_SEPARATOR, self.versplit_action,
-                       self.horsplit_action, self.close_action]
-            if plugin is not None:
-                if plugin.undocked_window:
-                    actions += [MENU_SEPARATOR, plugin.dock_action]
-                else:
-                    actions += [MENU_SEPARATOR, self.new_window_action]
+            window = self.window()
+            close_window_action = create_action(
+                self, _("Close window"),
+                icon=ima.icon('close_pane'),
+                triggered=window.close)
+            actions += [MENU_SEPARATOR, self.new_window_action,
+                        close_window_action]
+        elif plugin is not None:
+            if plugin.undocked_window is not None:
+                actions += [MENU_SEPARATOR, plugin.dock_action]
+            else:
+                actions += [MENU_SEPARATOR, self.new_window_action,
+                            plugin.undock_action, plugin.close_plugin_action]
+
         return actions
 
     def reset_orientation(self):
@@ -2996,6 +2999,7 @@ def __init__(self):
         self.dock_action = None
         self.undock_action = None
         self.close_plugin_action = None
+        self.undocked_window = None
         menu_actions = []
 
         self.editorstacks = []


Test patch: