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

Issue:
runfile changes the current tab in the editor
<!--- **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

First of all, I guess this is more of an inconvenience than a real problem. Since Spyder 4.0.0b7, calling `runfile("someFile.py")` in the iPython console produces the following behavior :
- If `someFile.py` is not open in the editor, just execute `runfile`
- If `someFile.py` is open in the editor, execute `runfile` **and switch to the corresponding tab**

Sometimes you need to run / re-run some main file many times while working on another, and having to switch back from the former to the latter each time you execute runfile (or press F6) is quite annoying.

It seems that this behavior was not present in Spyder 4.0.0b6.

### What steps reproduce the problem?

1. Open two files `a.py` and `b.py` in the editor
2. Go to tab of `b.py` and execute `runfile("a.py")` (or press F6 after having run `a.py` beforehand)

## 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.0rc1 
* Python version: Python 3.6.9 64-bit 
* Qt version: Qt 5.9.6
* PyQt version: PyQt5 5.9.2
* Operating System name/version:  Ubuntu 18.04  /  Linux 4.15.0-66-generic 



Discussion:
@impact27, could you take a look at this one?
How about `runcell`? Should runcell switch to the tab? I think it makes sense for runcell at least.

Resolving patch:
diff --git a/spyder/plugins/ipythonconsole/widgets/shell.py b/spyder/plugins/ipythonconsole/widgets/shell.py
--- a/spyder/plugins/ipythonconsole/widgets/shell.py
+++ b/spyder/plugins/ipythonconsole/widgets/shell.py
@@ -528,9 +528,7 @@ def get_editor(self, filename):
         if index is None:
             return None
 
-        editor = editorstack.data[index].editor
-        editorstack.set_stack_index(index)
-        return editor
+        return editorstack.data[index].editor
 
     def get_editorstack(self):
         """Get the current editorstack."""


Test patch:
Repository: spyder-ide/spyder

Issue:
Variable Explorer crashes when viewing Numpy matrix with inf
The following code creates the object testMatrix , and double-clicking on it in variable explorer results in error and immediate crash.

`import numpy as np`
`testMatrix = np.matrix(np.ones((20,20)) * np.inf)`
I cannot capture the error message and there is no crash log file.

Spyder Version: 3.3.1
Python Version: 3.7.0 Anaconda
Operating system: MacOS Mojave


Discussion:
Thanks for reporting. We'll take a look at this in a future release.
I'm having this issue too.

Resolving patch:
diff --git a/spyder/plugins/variableexplorer/widgets/arrayeditor.py b/spyder/plugins/variableexplorer/widgets/arrayeditor.py
--- a/spyder/plugins/variableexplorer/widgets/arrayeditor.py
+++ b/spyder/plugins/variableexplorer/widgets/arrayeditor.py
@@ -167,8 +167,12 @@ def __init__(self, data, format="%.6g", xlabels=None, ylabels=None,
             self.dhue = None
             self.bgcolor_enabled = False
 
-        # Deactivate coloring for object arrays
-        if self._data.dtype.name == 'object':
+        # Array with infinite values cannot display background colors and
+        # crashes. See: spyder-ide/spyder#8093
+        self.has_inf = np.inf in data
+
+        # Deactivate coloring for object arrays or arrays with inf values
+        if self._data.dtype.name == 'object' or self.has_inf:
             self.bgcolor_enabled = False
 
         # Use paging when the total size, number of rows or number of
@@ -289,7 +293,7 @@ def data(self, index, role=Qt.DisplayRole):
         elif role == Qt.TextAlignmentRole:
             return to_qvariant(int(Qt.AlignCenter|Qt.AlignVCenter))
         elif (role == Qt.BackgroundColorRole and self.bgcolor_enabled
-                and value is not np.ma.masked):
+                and value is not np.ma.masked and not self.has_inf):
             try:
                 hue = (self.hue0 +
                        self.dhue * (float(self.vmax) - self.color_func(value))


Test patch:
diff --git a/spyder/plugins/variableexplorer/widgets/tests/test_arrayeditor.py b/spyder/plugins/variableexplorer/widgets/tests/test_arrayeditor.py
--- a/spyder/plugins/variableexplorer/widgets/tests/test_arrayeditor.py
+++ b/spyder/plugins/variableexplorer/widgets/tests/test_arrayeditor.py
@@ -99,6 +99,14 @@ def test_arrayeditor_format(qtbot):
     assert contents == "1.000000000000000000e+00\n2.000000000000000000e+00\n"
 
 
+def test_arrayeditor_with_inf_array(qtbot, recwarn):
+    """See: spyder-ide/spyder#8093"""
+    arr = np.array([np.inf])
+    res = launch_arrayeditor(arr, "inf array")
+    assert len(recwarn) == 0
+    assert arr == res
+
+
 def test_arrayeditor_with_string_array(qtbot):
     arr = np.array(["kjrekrjkejr"])
     assert arr == launch_arrayeditor(arr, "string array")
Repository: spyder-ide/spyder

Issue:
String "Run in console's namespace instead of an empty one" translated but still show English on UI
## Problem Description

The following string is translated in PO files, but on UI it still shows in English.

spyder/preferences/runconfig.py:46":
msgid "Run in consoleâs namespace instead of an empty one"

It seems to be related to the special characters. In PO files it is:
msgid "Run in consoleâs namespace instead of an empty one"
but in source file it is:
CONSOLE_NAMESPACE = _("Run in console’s namespace instead of an empty one").


Discussion:
We will look into it! thanks

Resolving patch:
diff --git a/spyder/preferences/runconfig.py b/spyder/preferences/runconfig.py
--- a/spyder/preferences/runconfig.py
+++ b/spyder/preferences/runconfig.py
@@ -43,7 +43,7 @@
 ALWAYS_OPEN_FIRST_RUN_OPTION = 'open_on_firstrun'
 
 CLEAR_ALL_VARIABLES = _("Remove all variables before execution")
-CONSOLE_NAMESPACE = _("Run in console’s namespace instead of an empty one")
+CONSOLE_NAMESPACE = _("Run in console's namespace instead of an empty one")
 POST_MORTEM = _("Directly enter debugging when errors appear")
 INTERACT = _("Interact with the Python console after execution")
 


Test patch:
Repository: spyder-ide/spyder

Issue:
Regression: Indent guides broken in any Editor split panel except the first
As requested by @ccordoba12 . This is a serious regression in a major new feature that's been present since Beta 1, so it should presumably be fixed before the final release.

PR #10782 adds a new system for indent guides, but they are broken (don't appear at all) in any split Editor panel that isn't the first, leading me to initially think that they weren't working at all until I could get them to work in the first panel. Ergo, this should be fixed.


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

Resolving patch:
diff --git a/spyder/plugins/editor/widgets/codeeditor.py b/spyder/plugins/editor/widgets/codeeditor.py
--- a/spyder/plugins/editor/widgets/codeeditor.py
+++ b/spyder/plugins/editor/widgets/codeeditor.py
@@ -854,9 +854,12 @@ def setup_editor(self,
         # Scrolling past the end
         self.set_scrollpastend_enabled(scroll_past_end)
 
-        # Line number area
+        # Line number area and indent guides
         if cloned_from:
             self.setFont(font) # this is required for line numbers area
+            # Needed to show indent guides for splited editor panels
+            # See spyder-ide/spyder#10900
+            self.patch = cloned_from.patch
         self.toggle_line_numbers(linenumbers, markers)
 
         # Lexer


Test patch:
Repository: spyder-ide/spyder

Issue:
No plotting available for some variables in Variable Explorer
Spyder 4.0.0rc3

There's no plotting available for some of the variables in Variable Explorer. Neither on the pane's toolbar or on right click:

<img src="https://user-images.githubusercontent.com/15214418/70036433-14c5e980-15b5-11ea-87a0-f385132e2da0.png" width="500"/>

For most of the others it works:
<img src="https://user-images.githubusercontent.com/15214418/70036663-830aac00-15b5-11ea-9e25-3466804f78bb.png" width="500"/>

Even though in this case one variable is made from the other one like so:
```python
energy = 10**(logenergy/10)
```

Also there is no Plot button on the pane's toolbar.

It's hard to reproduce in a new IPython console though ...



Discussion:
@gerazov, please post some code that generates an array for which plotting is not available.
It's really elusive - I took down parts of my code and this is a minimum working example. If you take away anything, e.g. the `mse`, it starts working.

```python
import numpy as np
import matplotlib.pyplot as plt

def get_mse(target, synth):
    weights = np.sum(target, axis=0)
    mse = None
    return mse, weights

spec = np.random.rand(128, 159)
mse, energy_mel = get_mse(spec, spec)
mse, energy_spec = get_mse(spec, spec)
```
If you run this then `energy_spec` cannot be plotted from the Variable Explorer. 

<img src="https://user-images.githubusercontent.com/15214418/70147174-01de1280-16a4-11ea-99a2-9581bb20eb19.png" width="500"/>

This persists IPython Console restarts, and restarting Spyder. See if you can confirm.

@dalthviz, can you reproduce this one with @gerazov example above?
@ccordoba12 yep I can reproduce this, no plot action in shown in the context menu of the Variable Explorer

Resolving patch:
diff --git a/spyder/plugins/variableexplorer/widgets/collectionseditor.py b/spyder/plugins/variableexplorer/widgets/collectionseditor.py
--- a/spyder/plugins/variableexplorer/widgets/collectionseditor.py
+++ b/spyder/plugins/variableexplorer/widgets/collectionseditor.py
@@ -709,7 +709,7 @@ def refresh_menu(self):
 
     def refresh_plot_entries(self, index):
         if index.isValid():
-            key = self.source_model.get_key(index)
+            key = self.proxy_model.get_key(index)
             is_list = self.is_list(key)
             is_array = self.is_array(key) and self.get_len(key) != 0
             condition_plot = (is_array and len(self.get_array_shape(key)) <= 2)


Test patch:
Repository: spyder-ide/spyder

Issue:
Feature request: add a minimum height for the slider range of the scrollflag panel
## Problem Description

The slider range of the scrollflag panel is really useful for navigating quickly from one place to another in a file.

By design, the height of the slider range is scaled to the total height of the file. However, unlike the scrollbar's slider, there is no minimum height set on the scrollflag panel's slider range. So for files with a lot of lines, it becomes very small and can be hard to see on the screen.

I was thinking that maybe we should set a minimum height for the scrollflag panel's slider range. We could use the same minimum value as that used for the scrollbar?

![image](https://user-images.githubusercontent.com/10170372/70720557-00bf6d80-1cc2-11ea-84b1-89428baee5d2.png)


Discussion:
> I was thinking that maybe we should set a minimum height for the scrollflag panel's slider range. We could use the same minimum value as that used for the scrollbar?

Good suggestion @jnsebgosselin! I agree with it!

Since I don't this to be a big change, you can make it for `4.x`.

Resolving patch:
diff --git a/spyder/plugins/editor/panels/scrollflag.py b/spyder/plugins/editor/panels/scrollflag.py
--- a/spyder/plugins/editor/panels/scrollflag.py
+++ b/spyder/plugins/editor/panels/scrollflag.py
@@ -226,6 +226,14 @@ def get_vertical_offset(self):
         groove_rect = self.get_scrollbar_groove_rect()
         return groove_rect.y()
 
+    def get_slider_min_height(self):
+        """
+        Return the minimum height of the slider range based on that set for
+        the scroll bar's slider.
+        """
+        return QApplication.instance().style().pixelMetric(
+            QStyle.PM_ScrollBarSliderMin)
+
     def get_scrollbar_groove_rect(self):
         """Return the area in which the slider handle may move."""
         vsb = self.editor.verticalScrollBar()
@@ -298,6 +306,7 @@ def make_slider_range(self, cursor_pos, scale_factor, offset, groove_rect):
         vsb = self.editor.verticalScrollBar()
         slider_height = self.value_to_position(
             vsb.pageStep(), scale_factor, offset) - offset
+        slider_height = max(slider_height, self.get_slider_min_height())
 
         # Calcul the minimum and maximum y-value to constraint the slider
         # range indicator position to the height span of the scrollbar area


Test patch:
Repository: spyder-ide/spyder

Issue:
Copying or duplicating multiple selected lines deselects last line each time
Currently on Spyder 4.0.0 but this one was there in Spyder 3 too, yet it seems no one was bothered enough to report it :smile: 

There's a small but irritating bug in the way `copy line` and `duplicate line` work for a selection of lines in the Editor.

If you select the lines up to the next new line, which is the normal way to select multiple lines using the keyboard, that each time you do `copy line` (`Alt+Shift+Down`) or `duplicate line` (`Alt+Shift+Up`) it forgets about the last copied line, i.e. deselects it. Thus, with each new copy, a smaller number number of the originally selected lines is copied, like so:

<img src="https://user-images.githubusercontent.com/15214418/70788311-e86a5400-1d90-11ea-86c3-5461af7acff7.gif" width="300" />

On the other hand if you select the lines up to the end of the last line, which takes more keystrokes to do, the copying works as expected:

<img src="https://user-images.githubusercontent.com/15214418/70788400-18195c00-1d91-11ea-8d4a-06c529e8086b.gif" width="300" />




Discussion:
I can replicate this. Thanks for reporting.

I think this is something I can fix if you need @ccordoba12.
Yes, please do @jnsebgosselin. And thanks for your help!

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
@@ -617,7 +617,9 @@ def __duplicate_line_or_selection(self, after_current_line=True):
         """Duplicate current line or selected text"""
         cursor = self.textCursor()
         cursor.beginEditBlock()
+        cur_pos = cursor.position()
         start_pos, end_pos = self.__save_selection()
+        end_pos_orig = end_pos
         if to_text_string(cursor.selectedText()):
             cursor.setPosition(end_pos)
             # Check if end_pos is at the start of a block: if so, starting
@@ -646,12 +648,16 @@ def __duplicate_line_or_selection(self, after_current_line=True):
             cursor.setPosition(start_pos)
             cursor.movePosition(QTextCursor.StartOfBlock)
             start_pos += len(text)
-            end_pos += len(text)
+            end_pos_orig += len(text)
+            cur_pos += len(text)
 
         cursor.insertText(text)
         cursor.endEditBlock()
         self.setTextCursor(cursor)
-        self.__restore_selection(start_pos, end_pos)
+        if cur_pos == start_pos:
+            self.__restore_selection(end_pos_orig, start_pos)
+        else:
+            self.__restore_selection(start_pos, end_pos_orig)
 
     def duplicate_line(self):
         """


Test patch:
Repository: spyder-ide/spyder

Issue:
"Select All" in Variable Explorer for DataFrames
Hi, 

thanks for the great Spyder 4 release. 

I have noticed that in contrast to Spyder 3, when opening a pandas DataFrame (with index and column names) in the variable explorer and hitting "Select All", this will **not** copy the index / column names. For copying and pasting to external applications it would be great if the old behaviour from Spyder 3 that also copied index and column headers could be re-established.


Discussion:
Thanks for reporting. This is a valid request.

@dalthviz, please take a look at this one.

Resolving patch:
diff --git a/spyder/plugins/variableexplorer/widgets/dataframeeditor.py b/spyder/plugins/variableexplorer/widgets/dataframeeditor.py
--- a/spyder/plugins/variableexplorer/widgets/dataframeeditor.py
+++ b/spyder/plugins/variableexplorer/widgets/dataframeeditor.py
@@ -594,7 +594,9 @@ def copy(self):
             return
         (row_min, row_max,
          col_min, col_max) = get_idx_rect(self.selectedIndexes())
-        index = header = False
+        # Copy index and header too (equal True).
+        # See spyder-ide/spyder#11096
+        index = header = True
         df = self.model().df
         obj = df.iloc[slice(row_min, row_max + 1),
                       slice(col_min, col_max + 1)]


Test patch:
Repository: spyder-ide/spyder

Issue:
Simple typo: witdh -> width
# Issue Type

[x] Bug (Typo)

# Steps to Replicate

1. Examine spyder/plugins/plots/widgets/figurebrowser.py.
2. Search for `witdh`.

# Expected Behaviour

1. Should read `width`.




Discussion:

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
@@ -725,7 +725,7 @@ def save_figure_as(self, fig, fmt):
     # ---- Thumbails Handlers
     def _calculate_figure_canvas_width(self, thumbnail):
         """
-        Calculate the witdh the thumbnail's figure canvas need to have for the
+        Calculate the width the thumbnail's figure canvas need to have for the
         thumbnail to fit the scrollarea.
         """
         extra_padding = 10 if sys.platform == 'darwin' else 0


Test patch:
Repository: spyder-ide/spyder

Issue:
Replace text is always enabled even for read-only plugins.
<!--- **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

![image](https://user-images.githubusercontent.com/10170372/71925972-4441b600-3160-11ea-8fd9-6bef906a7adf.png)

### What steps reproduce the problem?

1. Press Ctrl+R in the IPython or Help plugin

### What is the expected output? What do you see instead?

The replace text widget should not be enabled for those plugins.

## Versions

* Spyder 4.1.0.dev0 (Commit: 9669a9b31) 
* Python 3.7.3 64-bit | Qt 5.9.6 | PyQt5 5.9.2 | Windows 10 



Discussion:

Resolving patch:
diff --git a/spyder/widgets/findreplace.py b/spyder/widgets/findreplace.py
--- a/spyder/widgets/findreplace.py
+++ b/spyder/widgets/findreplace.py
@@ -257,17 +257,6 @@ def update_search_combo(self):
     def update_replace_combo(self):
         self.replace_text.lineEdit().returnPressed.emit()
 
-    def toggle_replace_widgets(self):
-        if self.enable_replace:
-            # Toggle replace widgets
-            if self.replace_widgets[0].isVisible():
-                self.hide_replace()
-                self.hide()
-            else:
-                self.show_replace()
-                if len(to_text_string(self.search_text.currentText())) > 0:
-                    self.replace_text.setFocus()
-
     @Slot(bool)
     def toggle_highlighting(self, state):
         """Toggle the 'highlight all results' feature"""
@@ -325,9 +314,10 @@ def hide(self):
 
     def show_replace(self):
         """Show replace widgets"""
-        self.show(hide_replace=False)
-        for widget in self.replace_widgets:
-            widget.show()
+        if self.enable_replace:
+            self.show(hide_replace=False)
+            for widget in self.replace_widgets:
+                widget.show()
 
     def hide_replace(self):
         """Hide replace widgets"""


Test patch:
Repository: spyder-ide/spyder

Issue:
Missing space when rendering NumPy docstrings
In NumPy-style docs such as this snippet below:
```
Parameters
----------
some_param : type of this parameter
    Explanation about the parameter
```

Spyder's help renders the type of the parameter without any spacing from the name. Attached is a screenshot highlighting this:
![spyder_format](https://user-images.githubusercontent.com/11860098/61712621-66d14580-ad5f-11e9-84fe-8f25edd652ca.png)

Sphinx itself adds that extra separating space, as can be seen in e.g. the official numpy docs:
https://docs.scipy.org/doc/numpy-1.15.0/reference/generated/numpy.arange.html


Discussion:
That's a Sphinx problem and it changes from version to version.

What's your Sphinx version?
@ccordoba12 : it's Sphinx 2.1.2 (latest stable version). If I pick some random package and build html docs through Sphinx with the alabaster theme, they don't look like they're missing a space.
Roll back to sphinx 1.8.5  I raised this issue a while ago [https://github.com/spyder-ide/spyder/issues/created_by/Dan-Patterson](url)
@Dan-Patterson, your link above doesn't show any issues.
https://github.com/spyder-ide/spyder/issues/9527 missed the link... issue 9527.  I have also seen references to pinning to sphinx 1.8.5 with other packages, but I don't have a list.  
Thanks! I closed that issue in favor of this one because this has a more detailed explanation of the problem.
@dalthviz, please take care of this one as soon as you can. We need it for @juanis2112's work on improving our docs.

Resolving patch:
diff --git a/spyder/plugins/help/utils/sphinxify.py b/spyder/plugins/help/utils/sphinxify.py
--- a/spyder/plugins/help/utils/sphinxify.py
+++ b/spyder/plugins/help/utils/sphinxify.py
@@ -50,6 +50,7 @@
 CONFDIR_PATH = get_module_source_path('spyder.plugins.help.utils')
 CSS_PATH = osp.join(CONFDIR_PATH, 'static', 'css')
 DARK_CSS_PATH = osp.join(CONFDIR_PATH, 'static', 'dark_css')
+BASE_CSS_PATH = osp.join(CONFDIR_PATH, 'static', 'base_css')
 JS_PATH = osp.join(CONFDIR_PATH, 'js')
 
 # To let Debian packagers redefine the MathJax and JQuery locations so they can
@@ -135,11 +136,13 @@ def generate_context(name='', argspec='', note='', math=False, collapse=False,
       'collapse': collapse,
       'img_path': img_path,
       # Static variables
+      'base_css_path': BASE_CSS_PATH,
       'css_path': css_path,
       'js_path': JS_PATH,
       'jquery_path': JQUERY_PATH,
       'mathjax_path': MATHJAX_PATH,
       'right_sphinx_version': '' if sphinx.__version__ < "1.1" else 'true',
+      'sphinx_version_2': '' if sphinx.__version__ < "2.0" else 'true',
       'platform': sys.platform
     }
 


Test patch: