internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: spyder-ide/spyder

Issue:
Tooltip doesn't disappear if generated on first line of editor
## Description

### What steps will reproduce the problem?

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

Have a function call with a big tool tip on the first line p of the editor file. Move the mouse over it so the tool tip for the function appears.

Move the mouse straight up out of the editor window and click the open file toolbar button. The tooltip does not disappear when the mouse leaves the editor area, and the Open File dialog will open behind the tool tip. The tool tip cannot be cleared because now we are in a modal dialog. 

The Open File dialog is just an example of why this matters; it is not particularly relevant to the issue. 



## Versions

* Spyder version: 4.0.0 
* Python version: 3.7.3
* Qt version: 5.9.6
* PyQt5 version: 5.9.2
* Operating System: Windows 7

### Dependencies

```
cloudpickle >=0.5.0          :  1.2.2 (OK)
pygments >=2.0               :  2.5.2 (OK)
qtconsole >=4.6.0            :  4.6.0 (OK)
nbconvert >=4.0              :  5.6.1 (OK)
sphinx >=0.6.6               :  2.2.2 (OK)
pylint >=0.25                :  2.4.4 (OK)
psutil >=0.3                 :  5.6.7 (OK)
qtawesome >=0.5.7            :  0.6.0 (OK)
qtpy >=1.5.0                 :  1.9.0 (OK)
pickleshare >=0.4            :  0.7.5 (OK)
zmq >=17                     :  18.1.0 (OK)
chardet >=2.0.0              :  3.0.4 (OK)
numpydoc >=0.6.0             :  0.9.1 (OK)
spyder_kernels >=1.8.1;<2.0.0:  1.8.1 (OK)
qdarkstyle >=2.7             :  2.7 (OK)
atomicwrites >=1.2.0         :  1.3.0 (OK)
diff_match_patch >=20181111  :  20181111 (OK)
intervaltree                 :  None (OK)
watchdog                     :  None (OK)
keyring                      :  None (OK)
pexpect >=4.4.0              :  4.7.0 (OK)
pympler                      :  None (OK)
sympy >=0.7.3                :  1.4 (OK)
cython >=0.21                :  0.29.14 (OK)
IPython >=4.0                :  7.10.1 (OK)
matplotlib >=2.0.0           :  3.1.1 (OK)
pandas >=0.13.1              :  0.25.3 (OK)
numpy >=1.7                  :  1.17.4 (OK)
scipy >=0.17.0               :  1.3.2 (OK)
pyls >=0.31.2;<0.32.0        :  0.31.2 (OK)
rtree >=0.8.3                :  0.8.3 (OK)
```



Discussion:
I can reproduce this in linux
@dalthviz, please take a look at this one.

Resolving patch:
diff --git a/spyder/widgets/calltip.py b/spyder/widgets/calltip.py
--- a/spyder/widgets/calltip.py
+++ b/spyder/widgets/calltip.py
@@ -310,6 +310,9 @@ def eventFilter(self, obj, event):
             elif etype == QEvent.Leave:
                 self._leave_event_hide()
 
+            elif etype == QEvent.WindowBlocked:
+                self.hide()
+
         return super(CallTipWidget, self).eventFilter(obj, event)
 
     def timerEvent(self, event):


Test patch:
Repository: spyder-ide/spyder

Issue:
Editor: wrong tooltip position when undocking
The tooltips are being placed incorrectly after a docking or undocking of the Editor:

![tooltipe](https://user-images.githubusercontent.com/16781833/72756502-66ddc100-3b9b-11ea-8bfd-dedd2434cd37.gif)

As discussed with @ccordoba12 


Discussion:

Resolving patch:
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
@@ -2395,6 +2395,11 @@ def __modify_stack_title(self):
             state = finfo.editor.document().isModified()
             self.set_stack_title(index, state)
 
+    def __reset_tooltip(self):
+        """Reset tooltip tip info for all the editors."""
+        for index, finfo in enumerate(self.data):
+            finfo.editor.reset_tooltip()
+
     def refresh(self, index=None):
         """Refresh tabwidget"""
         if index is None:
@@ -2411,6 +2416,7 @@ def refresh(self, index=None):
             self.__refresh_readonly(index)
             self.__check_file_status(index)
             self.__modify_stack_title()
+            self.__reset_tooltip()
             self.update_plugin_title.emit()
         else:
             editor = None
diff --git a/spyder/widgets/calltip.py b/spyder/widgets/calltip.py
--- a/spyder/widgets/calltip.py
+++ b/spyder/widgets/calltip.py
@@ -45,7 +45,7 @@ def __init__(self, parent=None, as_tooltip=False):
         """
         Shows tooltips that can be styled with the different themes.
         """
-        super(ToolTipWidget, self).__init__(parent, Qt.ToolTip)
+        super(ToolTipWidget, self).__init__(None, Qt.ToolTip)
 
         # Variables
         self.completion_doc = None
@@ -200,6 +200,10 @@ def show_tip(self, point, tip, cursor=None, completion_doc=None):
             self.show()
         return True
 
+    def reset_tooltip(self):
+        """Reset tip to None."""
+        self.tip = None
+
     def mousePressEvent(self, event):
         """
         Reimplemented to hide it when focus goes out of the main window.
diff --git a/spyder/widgets/mixins.py b/spyder/widgets/mixins.py
--- a/spyder/widgets/mixins.py
+++ b/spyder/widgets/mixins.py
@@ -661,6 +661,10 @@ def hide_tooltip(self):
         self._last_point = None
         self.tooltip_widget.hide()
 
+    def reset_tooltip(self):
+        """Reset tooltip tip."""
+        self.tooltip_widget.reset_tooltip()
+
     #------EOL characters
     def set_eol_chars(self, text):
         """Set widget end-of-line (EOL) characters from text (analyzes text)"""


Test patch:
Repository: spyder-ide/spyder

Issue:
Change theme settings in external plugins is not possible
<!--- **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! --->

### Issue Report Checklist

* [x] Searched the [issues page](https://github.com/spyder-ide/spyder/issues?q=is%3Aissue) for similar reports
* [x] Read the relevant sections of the [Spyder Troubleshooting Guide](https://github.com/spyder-ide/spyder/wiki/Troubleshooting-Guide-and-FAQ) and followed its advice
* [x] Reproduced the issue after updating with ``conda update spyder`` (or ``pip``, if not using Anaconda)
* [x] Could not reproduce inside ``jupyter qtconsole`` (if console-related)
* [x] Tried basic troubleshooting (if a bug/error)
    * [x] Restarted Spyder
    * [x] Reset preferences with ``spyder --reset``
    * [x] Reinstalled the latest version of [Anaconda](https://www.anaconda.com/download/)
    * [x] Tried the other applicable steps from the Troubleshooting Guide
* [x] Completed the **Problem Description**, **Steps to Reproduce** and **Version** sections below


## Problem Description
When the theme changes in the appearance section of the configuration page, there's not a signal that is emitted to external plugins. So, the external plugins are unable to change their appearance according to the defined Spyder theme.




Discussion:
@ccordoba12 we could add a signal for this specific issue or generalize all plugins to receive all changed options and act accordingly?
> generalize all plugins to receive all changed options and act accordingly?

This sounds better to me, to not have a similar issue in the future related to another option.

Resolving patch:
diff --git a/spyder/preferences/appearance.py b/spyder/preferences/appearance.py
--- a/spyder/preferences/appearance.py
+++ b/spyder/preferences/appearance.py
@@ -209,6 +209,8 @@ def apply_settings(self, options):
                         ['color_scheme_name'])
                 if self.main.help is not None:
                     self.main.help.apply_plugin_settings(['color_scheme_name'])
+                for plugin in self.main.thirdparty_plugins:
+                    plugin.apply_plugin_settings(['color_scheme_name'])
                 self.update_combobox()
                 self.update_preview()
         else:
@@ -227,6 +229,8 @@ def apply_settings(self, options):
                         ['color_scheme_name'])
                 if self.main.help is not None:
                     self.main.help.apply_plugin_settings(['color_scheme_name'])
+                for plugin in self.main.thirdparty_plugins:
+                    plugin.apply_plugin_settings(['color_scheme_name'])
                 self.update_combobox()
                 self.update_preview()
         self.main.apply_settings()


Test patch:
Repository: spyder-ide/spyder

Issue:
Imports hang after debugging (Spyder 4)
[steps_to_reproduce.mp4](https://www.dropbox.com/s/v2ytdb6chj0g5gb/hang_steps.mp4?dl=0). Closing spyder and re-opening (again via Anaconda PowerShell Prompt) fixes the issue.

Unsure if this occurs if launching directly via `spyder` (not `--new-instance`), but currently running a TensorFlow session I rather not interrupt.


Discussion:
@impact27, could this be related to issue #11137?
It looks like the kernel doesn't like to be restarted while debugging. Steps to reproduce:
 - debug a file
 - when the `ipdb>` prompt is present, restart the kernel
 - the kernel is now broken

workaround: close and open a new kernel instead of restarting it.

Question: Why do we have logic to restart the kernel when the logic could be: close the kernel, open a new one?
>Question: Why do we have logic to restart the kernel when the logic could be: close the kernel, open a new one?

Restart will use the same port, close and open will create a new (and different port)

Resolving patch:
diff --git a/spyder/plugins/ipythonconsole/widgets/client.py b/spyder/plugins/ipythonconsole/widgets/client.py
--- a/spyder/plugins/ipythonconsole/widgets/client.py
+++ b/spyder/plugins/ipythonconsole/widgets/client.py
@@ -591,6 +591,7 @@ def _finalise_restart(self, reset=False):
             )
         else:
             # Reopen comm
+            sw._pdb_in_loop = False
             sw.spyder_kernel_comm.close()
             sw.spyder_kernel_comm.open_comm(sw.kernel_client)
 


Test patch:
Repository: spyder-ide/spyder

Issue:
Unintuitive behavior: Mouse wheel scrolling in editor steals keyboard focus
<!--- **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

With keyboard focus in the internal console, hovering the mouse cursor over the editor window and scrolling through the code with the mouse wheel places keyboard focus back into the editor window instead of leaving it in the console. This feels very counterintuitive to me compared to the general behavior in Windows, where the mouse wheel can be used to scroll through background windows without the active one losing its focus. 

It seems like a minor issue but it's very annoying to me because now I keep accidentally messing up my code instead of typing in the console. I also think Spyder 3 did not show this behavior; not quite sure, but I don't remember anything like this before upgrading to 4.

## 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.0.1
* Python version: Python 3.7.6 64-bit
* Qt version: 5.9.6 
* PyQt version: 5.9.2 
* Operating System name/version: Windows 10



Discussion:
@dalthviz, please take a look at this one.
I can confirm this in Ubuntu. Only the editor seems to steal focus.

Resolving patch:
diff --git a/spyder/plugins/editor/widgets/base.py b/spyder/plugins/editor/widgets/base.py
--- a/spyder/plugins/editor/widgets/base.py
+++ b/spyder/plugins/editor/widgets/base.py
@@ -1046,8 +1046,13 @@ def wheelEvent(self, event):
                         self.zoom_in.emit()
                 return
         QPlainTextEdit.wheelEvent(self, event)
+        # Needed to prevent stealing focus to the find widget when scrolling
+        # See spyder-ide/spyder#11502
+        current_widget = QApplication.focusWidget()
         self.hide_completion_widget()
         self.highlight_current_cell()
+        if current_widget is not None:
+            current_widget.setFocus()
 
     def position_widget_at_cursor(self, widget):
         # Retrieve current screen height


Test patch:
Repository: spyder-ide/spyder

Issue:
Unable to restart Spyder: FileNotFoundError - 'external-deps'
<!--- **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! --->

### Issue Report Checklist

* [x] Searched the [issues page](https://github.com/spyder-ide/spyder/issues?q=is%3Aissue) for similar reports
* [x] Completed the **Problem Description**, **Steps to Reproduce** and **Version** sections below

## Problem Description

When restarting Spyder from dev (for example to change the language) an error raises in the console/terminal.

### What steps reproduce the problem?

1. Select a new language from the preferences.
2. Accept restarting Spyder.

### What is the expected output? What do you see instead?

Restart Spyder without errors.

### Paste Traceback/Error Below (if applicable)
<!--- Copy from error dialog or View > Panes > Internal Console --->

```python-traceback
(spyder4) C:\Users\Daniel\Documents\Spyder\spyder>python bootstrap.py
Executing Spyder from source checkout
Revision 549e04079, Branch: fixes_issue_11514
01. Patched sys.path with C:\Users\Daniel\Documents\Spyder\spyder
01-1. Patched sys.path with C:\Users\Daniel\Documents\Spyder\spyder\external-deps\spyder-kernels
02. PyQt5 is detected, selecting
03. Imported Spyder 4.1.0.dev0
    [Python 3.7.3 64bits, Qt 5.9.6, PyQt5 5.9.2 on Windows]
04. Running Spyder
Bootstrap completed in 00:00:00.7378

(spyder4) C:\Users\Daniel\Documents\Spyder\spyder>Executing Spyder from source checkout
Revision 549e04079, Branch: fixes_issue_11514
01. Patched sys.path with C:\Users\Daniel\Documents\Spyder\spyder
Traceback (most recent call last):
  File "C:\Users\Daniel\Documents\Spyder\spyder\bootstrap.py", line 132, in <module>
    for path in os.listdir('external-deps'):
FileNotFoundError: [WinError 3] El sistema no puede encontrar la ruta especificada: 'external-deps'
```

## 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.0.dev0 549e04079
* Python version: 3.7
* Qt version: 5.9
* PyQt version: 5.9
* Operating System name/version: Windows 10



Discussion:

Resolving patch:
diff --git a/bootstrap.py b/bootstrap.py
--- a/bootstrap.py
+++ b/bootstrap.py
@@ -128,9 +128,10 @@
 
 # Add external dependencies subrepo paths to be the next entries
 # (1, 2, etc) of sys.path
+DEPS_PATH = osp.join(DEVPATH, 'external-deps')
 i = 1
-for path in os.listdir('external-deps'):
-    external_dep_path = osp.join(DEVPATH, 'external-deps', path)
+for path in os.listdir(DEPS_PATH):
+    external_dep_path = osp.join(DEPS_PATH, path)
     sys.path.insert(i, external_dep_path)
     print("01-%d. Patched sys.path with %s" % (i, external_dep_path))
     i += 1


Test patch:
Repository: spyder-ide/spyder

Issue:
Show hidden files in the project explorer
Is it possible to show hidden files like ``.travis.yml`` or ``.coveragerc`` in the project explorer?

There is an option called "Show all files" under ``Preferences -> Files -> General``, but this doesn't make these files show up.

If it's not my fault by missing a checkbox, I think it's quite inconvenient that accessing necessary files for a python project is not possible through the project explorer.

System: Ubuntu 18.04
Spyder: 4.0.0rc3
Python: 3.6.9


Discussion:
@MuellerSeb you are correct, we will fix this for V4.1 !


To add: in windows, hidden folders (as in windows-hidden, rather than name starting with `.`) also don't show up in the `Files` pane browser, whereas files with a name starting with `.` show up as expected.

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
@@ -184,7 +184,8 @@ def __init__(self, parent=None):
     #---- Model
     def setup_fs_model(self):
         """Setup filesystem model"""
-        filters = QDir.AllDirs | QDir.Files | QDir.Drives | QDir.NoDotAndDotDot
+        filters = (QDir.AllDirs | QDir.Files | QDir.Drives
+                   | QDir.NoDotAndDotDot | QDir.Hidden)
         self.fsmodel = QFileSystemModel(self)
         self.fsmodel.setFilter(filters)
         self.fsmodel.setNameFilterDisables(False)


Test patch:
Repository: spyder-ide/spyder

Issue:
Options for different modes of documentation are not available when the Help Pane is undocked. 
<!--- **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
 
Options for the pane's menu are deactivated when the pane is undocked

![Screen Shot 2020-02-18 at 2 52 19 PM](https://user-images.githubusercontent.com/18587879/74772703-829dbb00-525e-11ea-85e1-6ac2ac31317f.png)

### What steps reproduce the problem?

1. 
2. 
3. 

### What is the expected output? What do you see 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: 
* Python version: 
* Qt version: 
* PyQt version: 
* Operating System name/version: 

### Dependencies
<!--- Please go to the menu entry Help > Dependencies,
press the Copy to clipboard button and paste below --->

```
PASTE DEPENDENCIES HERE
```



Discussion:
@ccordoba12 @dalthviz 
@dalthviz, please take a look at this one ASAP.

Resolving patch:
diff --git a/spyder/plugins/help/plugin.py b/spyder/plugins/help/plugin.py
--- a/spyder/plugins/help/plugin.py
+++ b/spyder/plugins/help/plugin.py
@@ -45,6 +45,7 @@ class Help(SpyderPluginWidget):
     CONF_FILE = False
     LOG_PATH = get_conf_path(CONF_SECTION)
     FONT_SIZE_DELTA = DEFAULT_SMALL_DELTA
+    DISABLE_ACTIONS_WHEN_HIDDEN = False  # SpyderPluginWidget class attribute
 
     # Signals
     focus_changed = Signal()


Test patch:
Repository: spyder-ide/spyder

Issue:
Plots should remember last saved path
Python 4.0.0rc3

I really like the Plots pane - chasing down open figures was a lot of hassle ...

It would be nice if the Plot pane remembers the last folder for saving - just so you don't have to navigate down the same path on every save. Currently it opens the current working directory.


Discussion:
We could add this to the CONF and stored the last saved dir @jnsebgosselin ?
Yes, I will add this, this is a good idea.

Thanks for the suggestion @gerazov 
np guys - thanks for everything you're doing - keep up the good work! :clap: 

you know yesterday I saved all my 27 plots with one click, and I had to redo this four times - something that would take a gruesome hour or so to do the old way window by window. 

So thank you!

Resolving patch:
diff --git a/spyder/plugins/plots/widgets/figurebrowser.py b/spyder/plugins/plots/widgets/figurebrowser.py
--- a/spyder/plugins/plots/widgets/figurebrowser.py
+++ b/spyder/plugins/plots/widgets/figurebrowser.py
@@ -731,10 +731,11 @@ def eventFilter(self, widget, event):
     def save_all_figures_as(self):
         """Save all the figures to a file."""
         self.redirect_stdio.emit(False)
-        dirname = getexistingdirectory(self, caption='Save all figures',
-                                       basedir=getcwd_or_home())
+        save_dir = CONF.get('plots', 'save_dir', getcwd_or_home())
+        dirname = getexistingdirectory(self, 'Save all figures', save_dir)
         self.redirect_stdio.emit(True)
         if dirname:
+            CONF.set('plots', 'save_dir', dirname)
             return self.save_all_figures_todir(dirname)
 
     def save_all_figures_todir(self, dirname):
@@ -765,7 +766,8 @@ def save_figure_as(self, fig, fmt):
             'image/jpeg': ('.jpg', 'JPEG (*.jpg;*.jpeg;*.jpe;*.jfif)'),
             'image/svg+xml': ('.svg', 'SVG (*.svg);;PNG (*.png)')}[fmt]
 
-        figname = get_unique_figname(getcwd_or_home(), 'Figure', fext)
+        save_dir = CONF.get('plots', 'save_dir', getcwd_or_home())
+        figname = get_unique_figname(save_dir, 'Figure', fext)
 
         self.redirect_stdio.emit(False)
         fname, fext = getsavefilename(
@@ -775,6 +777,7 @@ def save_figure_as(self, fig, fmt):
         self.redirect_stdio.emit(True)
 
         if fname:
+            CONF.set('plots', 'save_dir', osp.dirname(fname))
             save_figure_tofile(fig, fmt, fname)
 
     # ---- Thumbails Handlers


Test patch:
Repository: spyder-ide/spyder

Issue:
Saving a protected file hangs Spyder
Here protected means "read only".
Actually I've tried to fix a python package (.py) directly in spyder, it hanged upon saving, instead than rejected the save without administrator rights.
[Window, last master, Python 3.6]


Discussion:
Thanks for reporting. We'll fix it after we release Spyder 4.
(Still running into this in Spyder 4.0.1.  Was very confused...)
@steff456, please take a look at this one asap.
@dalthviz, please take a look at this one to see if you can reproduce it. @steff456 tried to generate the reported error on Windows and macOS, but she was unable to.
@ccordoba12 I was able to reproduce this trying to modify a file under `Program Files` on Windows (where admin rights are needed to modify files and usually users have `Read and Execution` rights only).
Note: After testing seems like an issue with `atomicwrites` trying to create a temporary file using `tempfile` which in turn tries to get a temporary dir in `_get_default_tempdir` where a loop takes place and is the one causing the crash (it uses `os.access` which doesn't work well on Windows continuing the loop since the logic validation gives `True` even when the user doesn't have write access)
Thanks @dalthviz! Please talk to @steff456 to let her know how to reproduce this problem and how you think it could be fixed.
Note: python bugs related to `tempfile` hanging in Windows https://bugs.python.org/issue1473760 https://bugs.python.org/issue22107

Resolving patch:
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
@@ -2329,6 +2329,15 @@ def __refresh_readonly(self, index):
             if not osp.isfile(finfo.filename):
                 # This is an 'untitledX.py' file (newly created)
                 read_only = False
+            elif os.name == 'nt':
+                try:
+                    # Try to open the file to see if its permissions allow
+                    # to write on it
+                    # Fixes spyder-ide/spyder#10657
+                    fd = os.open(finfo.filename, os.O_RDWR)
+                    os.close(fd)
+                except (IOError, OSError):
+                    read_only = True
             finfo.editor.setReadOnly(read_only)
             self.readonly_changed.emit(read_only)
 


Test patch: