Repository: spyder-ide/spyder

Issue:
Spyder doesn't create a new folder in project explorer
<!--- **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
Creating a new folder using project explorer doesn't work in Spyder (4.1.5).


### What steps reproduce the problem?
![spyder_issue](https://user-images.githubusercontent.com/25546774/92302788-1753d600-ef6f-11ea-977e-724a219fa9f2.gif)

### What is the expected output? What do you see instead?
Expected outcome is a new folder created. I'm getting an error message instead.


### Paste Traceback/Error Below (if applicable)
<!--- Copy from error dialog or View > Panes > Internal Console --->

```python-traceback

PASTE TRACEBACK HERE

```

## 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: 4.1.5
* Python version: 3.7.7
* Qt version: 
* PyQt version: 
* Operating System name/version: Windows 10

### Dependencies
<!--- Please go to the menu entry Help > Dependencies,
press the Copy to clipboard button and paste below --->

```

# 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)
diff_match_patch >=20181111    :  20200713 (OK)
intervaltree                   :  None (OK)
IPython >=4.0                  :  7.18.1 (OK)
jedi =0.17.1                   :  0.17.1 (OK)
nbconvert >=4.0                :  5.6.1 (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.6.1 (OK)
pylint >=1.0                   :  2.6.0 (OK)
pyls >=0.34.0;<1.0.0           :  0.34.1 (OK)
qdarkstyle >=2.8               :  2.8.1 (OK)
qtawesome >=0.5.7              :  0.7.2 (OK)
qtconsole >=4.6.0              :  4.7.6 (OK)
qtpy >=1.5.0                   :  1.9.0 (OK)
rtree >=0.8.3                  :  0.9.4 (OK)
sphinx >=0.6.6                 :  3.2.1 (OK)
spyder_kernels >=1.9.4;<1.10.0 :  1.9.4 (OK)
watchdog                       :  None (OK)
zmq >=17                       :  19.0.1 (OK)

# Optional:
cython >=0.21                  :  0.29.21 (OK)
matplotlib >=2.0.0             :  3.3.1 (OK)
numpy >=1.7                    :  1.19.1 (OK)
pandas >=0.13.1                :  1.1.1 (OK)
scipy >=0.17.0                 :  1.5.2 (OK)
sympy >=0.7.3                  :  1.6.2 (OK)
```





Discussion:
Hey @marekkolman, thanks for reporting. This is definitely a bug and we'll fix it in our next version. 
The cause of the problem is the first element of `level_list`. It should only contain drive letter and colon (in case of Windows), however it looks like this: `OS (C:)` .  Because of that, `os.mdkir()` function throws an exception
https://github.com/spyder-ide/spyder/blob/1a1c67a2c92750b2d34aab613192b53713a5eefd/spyder/plugins/explorer/widgets/explorer.py#L434-L452
@akwasigroch, thanks a lot for giving us a hand with this! Would you like to submit a pull request to fix it?

If you do, please read our [Contributing guide](https://github.com/spyder-ide/spyder/blob/master/CONTRIBUTING.md) before doing it.

Resolving patch:
diff --git a/spyder/plugins/explorer/widgets/explorer.py b/spyder/plugins/explorer/widgets/explorer.py
--- a/spyder/plugins/explorer/widgets/explorer.py
+++ b/spyder/plugins/explorer/widgets/explorer.py
@@ -439,17 +439,10 @@ def create_file_new_actions(self, fnames):
             # Verify if the user is trying to add something new inside a folder
             # so it can be added in that folder and not in the rootpath
             # See spyder-ide/spyder#13444
-            level_list = []
-            current_index = self.currentIndex()
-            if current_index.isValid():
-                level_list.append(current_index.data())
-
-            while current_index.isValid():
-                current_index = current_index.parent()
-                if current_index.data() is not None:
-                    level_list.insert(0, current_index.data())
+            # See spyder-ide/spyder#13722
 
-            root_path = osp.join(*level_list)
+            current_index = self.currentIndex()
+            root_path = self.get_dirname(current_index)
 
         new_file_act = create_action(self, _("File..."),
                                      icon=ima.icon('TextFileIcon'),


Test patch: