Repository: spyder-ide/spyder

Issue:
Can't open new editor window
## Description

### What steps will reproduce the problem?

<!--- You can use Markdown here --->

i can not open window from tab
python 3.8
spyder 5.0.0 

### Traceback
```python-traceback
Traceback (most recent call last):
  File "c:\users\osama\appdata\local\programs\python\python38\lib\site-packages\spyder\plugins\editor\plugin.py", line 1647, in create_new_window
    oe_options = self.outlineexplorer.get_widget().get_options()
AttributeError: 'OutlineExplorerWidget' object has no attribute 'get_options'
Traceback (most recent call last):
  File "c:\users\osama\appdata\local\programs\python\python38\lib\site-packages\spyder\plugins\editor\plugin.py", line 1647, in create_new_window
    oe_options = self.outlineexplorer.get_widget().get_options()
AttributeError: 'OutlineExplorerWidget' object has no attribute 'get_options'
```

## Versions

* Spyder version: 5.0.0 
* Python version: 3.8.6
* Qt version: 5.12.10
* PyQt5 version: 5.12.3
* Operating System: Windows 10

### Dependencies

```

# Mandatory:
atomicwrites >=1.2.0          :  1.4.0 (OK)
chardet >=2.0.0               :  3.0.4 (OK)
cloudpickle >=0.5.0           :  1.6.0 (OK)
cookiecutter >=1.6.0          :  1.7.2 (OK)
diff_match_patch >=20181111   :  20200713 (OK)
intervaltree >=3.0.2          :  3.1.0 (OK)
IPython >=7.6.0               :  7.21.0 (OK)
jedi =0.17.2                  :  0.17.2 (OK)
jsonschema >=3.2.0            :  3.2.0 (OK)
keyring >=17.0.0              :  21.4.0 (OK)
nbconvert >=4.0               :  6.0.7 (OK)
numpydoc >=0.6.0              :  1.1.0 (OK)
paramiko >=2.4.0              :  2.7.2 (OK)
parso =0.7.0                  :  0.7.0 (OK)
pexpect >=4.4.0               :  4.8.0 (OK)
pickleshare >=0.4             :  0.7.5 (OK)
psutil >=5.3                  :  5.7.2 (OK)
pygments >=2.0                :  2.8.1 (OK)
pylint >=1.0                  :  2.6.0 (OK)
pyls >=0.36.2;<1.0.0          :  0.36.2 (OK)
pyls_black >=0.4.6            :  0.4.6 (OK)
pyls_spyder >=0.3.2           :  0.3.2 (OK)
qdarkstyle =3.0.2             :  3.0.2 (OK)
qstylizer >=0.1.10            :  0.1.10 (OK)
qtawesome >=0.5.7             :  1.0.1 (OK)
qtconsole >=5.0.3             :  5.0.3 (OK)
qtpy >=1.5.0                  :  1.9.0 (OK)
setuptools >=39.0.0           :  54.1.1 (OK)
sphinx >=0.6.6                :  3.2.1 (OK)
spyder_kernels >=2.0.1,<2.1.0 :  2.0.1 (NOK)
textdistance >=4.2.0          :  4.2.0 (OK)
three_merge >=0.1.1           :  0.1.1 (OK)
watchdog >=0.10.3;<2.0.0      :  0.10.3 (OK)
zmq >=17                      :  22.0.3 (OK)

# Optional:
cython >=0.21                 :  0.29.21 (OK)
matplotlib >=2.0.0            :  3.3.2 (OK)
numpy >=1.7                   :  1.19.5 (OK)
pandas >=1.1.1                :  1.2.3 (OK)
scipy >=0.17.0                :  1.5.2 (OK)
sympy >=0.7.3                 :  None (NOK)
```



Discussion:
Hi @Smsmadly,

Thanks for reporting, we will fix this issue for the next release. @andfoy can you please take a look at this one?

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
@@ -1644,10 +1644,8 @@ def switch_to_plugin(self):
             super(Editor, self).switch_to_plugin()
 
     def create_new_window(self):
-        oe_options = self.outlineexplorer.get_widget().get_options()
         window = EditorMainWindow(
-            self, self.stack_menu_actions, self.toolbar_list, self.menu_list,
-            outline_explorer_options=oe_options)
+            self, self.stack_menu_actions, self.toolbar_list, self.menu_list)
         window.add_toolbars_to_menu("&View", window.get_toolbars())
         window.load_toolbars()
         window.resize(self.size())
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
@@ -60,7 +60,8 @@
 from spyder.plugins.explorer.widgets.explorer import (
     show_in_external_file_explorer)
 from spyder.plugins.outlineexplorer.api import cell_name
-from spyder.utils.stylesheet import PANES_TABBAR_STYLESHEET
+from spyder.utils.stylesheet import (
+    APP_TOOLBAR_STYLESHEET, PANES_TABBAR_STYLESHEET)
 
 
 logger = logging.getLogger(__name__)
@@ -3069,7 +3070,9 @@ def set_layout_settings(self, settings, dont_goto=None):
 
 
 class EditorWidget(QSplitter):
-    def __init__(self, parent, plugin, menu_actions, outline_explorer_options):
+    CONF_SECTION = 'editor'
+
+    def __init__(self, parent, plugin, menu_actions):
         QSplitter.__init__(self, parent)
         self.setAttribute(Qt.WA_DeleteOnClose)
 
@@ -3093,15 +3096,15 @@ def __init__(self, parent, plugin, menu_actions, outline_explorer_options):
         self.find_widget = FindReplace(self, enable_replace=True)
         self.plugin.register_widget_shortcuts(self.find_widget)
         self.find_widget.hide()
+
+        # TODO: Check this initialization once the editor is migrated to the
+        # new API
         self.outlineexplorer = OutlineExplorerWidget(
+            'outline_explorer',
+            plugin,
             self,
-            show_fullpath=outline_explorer_options['show_fullpath'],
-            show_all_files=outline_explorer_options['show_all_files'],
-            group_cells=outline_explorer_options['group_cells'],
-            show_comments=outline_explorer_options['show_comments'],
-            sort_files_alphabetically=outline_explorer_options[
-                'sort_files_alphabetically'],
-            )
+            context=f'editor_window_{str(id(self))}'
+        )
         self.outlineexplorer.edit_goto.connect(
                      lambda filenames, goto, word:
                      plugin.load(filenames=filenames, goto=goto, word=word,
@@ -3144,9 +3147,6 @@ def register_editorstack(self, editorstack):
                      self.cursorpos_status.update_cursor_position)
         editorstack.sig_refresh_eol_chars.connect(self.eol_status.update_eol)
         self.plugin.register_editorstack(editorstack)
-        oe_btn = create_toolbutton(self)
-        oe_btn.setDefaultAction(self.outlineexplorer.visibility_action)
-        editorstack.add_corner_widgets_to_tabbar([5, oe_btn])
 
     def __print_editorstacks(self):
         logger.debug("%d editorstack(s) in editorwidget:" %
@@ -3162,16 +3162,14 @@ def unregister_editorstack(self, editorstack):
 
 
 class EditorMainWindow(QMainWindow):
-    def __init__(self, plugin, menu_actions, toolbar_list, menu_list,
-                 outline_explorer_options):
+    def __init__(self, plugin, menu_actions, toolbar_list, menu_list):
         QMainWindow.__init__(self)
         self.setAttribute(Qt.WA_DeleteOnClose)
 
         self.plugin = plugin
         self.window_size = None
 
-        self.editorwidget = EditorWidget(self, plugin, menu_actions,
-                                         outline_explorer_options)
+        self.editorwidget = EditorWidget(self, plugin, menu_actions)
         self.setCentralWidget(self.editorwidget)
 
         # Setting interface theme
@@ -3191,6 +3189,8 @@ def __init__(self, plugin, menu_actions, toolbar_list, menu_list,
             for title, object_name, actions in toolbar_list:
                 toolbar = self.addToolBar(title)
                 toolbar.setObjectName(object_name)
+                toolbar.setStyleSheet(str(APP_TOOLBAR_STYLESHEET))
+                toolbar.setMovable(False)
                 add_actions(toolbar, actions)
                 self.toolbars.append(toolbar)
         if menu_list:
@@ -3217,6 +3217,7 @@ def add_toolbars_to_menu(self, menu_title, actions):
         # Six is the position of the view menu in menus list
         # that you can find in plugins/editor.py setup_other_windows.
         view_menu = self.menus[6]
+        view_menu.setObjectName('checkbox-padding')
         if actions == self.toolbars and view_menu:
             toolbars = []
             for toolbar in self.toolbars:
diff --git a/spyder/plugins/outlineexplorer/widgets.py b/spyder/plugins/outlineexplorer/widgets.py
--- a/spyder/plugins/outlineexplorer/widgets.py
+++ b/spyder/plugins/outlineexplorer/widgets.py
@@ -297,6 +297,9 @@ class OutlineExplorerTreeWidget(OneColumnTree):
     CONF_SECTION = 'outline_explorer'
 
     def __init__(self, parent):
+        if hasattr(parent, 'CONTEXT_NAME'):
+            self.CONTEXT_NAME = parent.CONTEXT_NAME
+
         self.show_fullpath = self.get_conf('show_fullpath')
         self.show_all_files = self.get_conf('show_all_files')
         self.group_cells = self.get_conf('group_cells')
@@ -888,7 +891,10 @@ class OutlineExplorerWidget(PluginMainWidget):
     ENABLE_SPINNER = True
     CONF_SECTION = 'outline_explorer'
 
-    def __init__(self, name, plugin, parent=None):
+    def __init__(self, name, plugin, parent=None, context=None):
+        if context is not None:
+            self.CONTEXT_NAME = context
+
         super().__init__(name, plugin, parent)
 
         self.treewidget = OutlineExplorerTreeWidget(self)


Test patch: