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

Issue:
Editor: "move line up/down" commands broken when moving past a blank line
## Description

**Proper behavior:**
1. Place cursor on a line with some text on it, **where the next line also contains text:**
   ![initial conditions 1](https://cloud.githubusercontent.com/assets/12973799/12326901/77b996f4-baa1-11e5-9b6f-d8ab37839212.png)
2. Execute the 'move line down' command (not in the menu, but I have a keyboard shortcut assigned to it)
3. Observe that the original line has now swapped places with the line after it:
   ![proper result](https://cloud.githubusercontent.com/assets/12973799/12326917/957e7768-baa1-11e5-9447-ca7aa046c20e.png)

**Improper behavior:**
1. Place cursor on a line with some text on it, **where the next line is blank:**
   ![initial conditions 2](https://cloud.githubusercontent.com/assets/12973799/12326976/e1bf6862-baa1-11e5-8767-0c24c2b3c6c1.png)
2. Execute the same 'move line down' command
3. Observe that the cursor simply moves to the next line, and doesn't move any text:
   ![improper result](https://cloud.githubusercontent.com/assets/12973799/12327006/0e69a882-baa2-11e5-89b0-b4b566a067a4.png)
## Version and main components
- Spyder Version: 3.0.0b1 
- Python Version: 2.7.10
- Qt Versions: 4.8.6, PyQt4 (API v2) 4.10.4 on Windows
## Optional dependencies

```
pyflakes >=0.5.0:  0.9.2 (OK)
pep8 >=0.6      :  1.6.2 (OK)
pygments >=1.6  :  2.0.2 (OK)
IPython >=3.0   :  3.2.0 (OK)
zmq >=13.0.0    :  14.7.0 (OK)
pandas >=0.13.1 :  0.16.2 (OK)
sphinx >=0.6.6  :  1.3.1 (OK)
rope >=0.9.4    :  0.9.4 (OK)
jedi >=0.8.1    :  0.8.1 (OK)
matplotlib >=1.0:  1.4.3 (OK)
sympy >=0.7.3   :  0.7.6 (OK)
pylint >=0.25   :  None (NOK)

```



Discussion:
@andfoy, please work on this one. The shortcuts to move lines up and down are `Alt+Up` and `Alt+Down` respectively.

In my tests, only `Alt+Down` is failing to move a line down when a blank line is below it.

Resolving patch:
diff --git a/spyder/widgets/sourcecode/base.py b/spyder/widgets/sourcecode/base.py
--- a/spyder/widgets/sourcecode/base.py
+++ b/spyder/widgets/sourcecode/base.py
@@ -867,6 +867,10 @@ def __move_line_or_selection(self, after_current_line=True):
 
         if after_current_line:
             text = to_text_string(cursor.block().text())
+            if len(text) == 0:
+                #If the next line is blank
+                sel_text = sel_text[0:-1]
+                sel_text = os.linesep + sel_text
             if not text:
                 cursor.insertText(sel_text)
                 cursor.endEditBlock()


Test patch:
Repository: spyder-ide/spyder

Issue:
F1 shortcut is hard-coded
## Description of your problem
Instead binding to Spyder documentation, I want to bind F1 to run.

**What steps will reproduce the problem?**

1. open keyboard shortcuts
2. rind run, bind to F1, apply, Ok.
3. restart

**What is the expected output? What do you see instead?**
Expected F1= run.
see F1= Spyder documentation. 

**Please provide any additional information below**


## Versions and main components

* Spyder Version:Spyder 3.0.2 
* Python Version:
* Operating system:
Python 3.5.2 64bits, Qt 5.7.0, PyQt5 5.7 on Darwin 

## Dependencies

Please go to the menu entry `Help > Optional Dependencies` (or
`Help > Dependencies`), press the button `Copy to clipboard`
and paste the contents below:



Discussion:
@andfoy, please work on this one. The idea is to make the F1 shortcut configurable instead of hard-coded in our interface (as it is right now).

Resolving patch:
diff --git a/spyder/app/mainwindow.py b/spyder/app/mainwindow.py
--- a/spyder/app/mainwindow.py
+++ b/spyder/app/mainwindow.py
@@ -915,9 +915,12 @@ def create_edit_action(text, tr_text, icon):
             spyder_doc = 'http://pythonhosted.org/spyder'
         else:
             spyder_doc = file_uri(spyder_doc)
-        doc_action = create_action( self, _("Spyder documentation"), shortcut="F1", 
-                                    icon=ima.icon('DialogHelpButton'),
-                                    triggered=lambda : programs.start_file(spyder_doc))
+        doc_action = create_action(self, _("Spyder documentation"),
+                                   icon=ima.icon('DialogHelpButton'),
+                                   triggered=lambda:
+                                   programs.start_file(spyder_doc))
+        self.register_shortcut(doc_action, "_",
+                               "spyder documentation")
 
         if self.help is not None:
             tut_action = create_action(self, _("Spyder tutorial"),
diff --git a/spyder/config/main.py b/spyder/config/main.py
--- a/spyder/config/main.py
+++ b/spyder/config/main.py
@@ -327,6 +327,7 @@
               '_/save current layout': "Shift+Alt+S",
               '_/layout preferences': "Shift+Alt+P",
               '_/show toolbars': "Alt+Shift+T",
+              '_/spyder documentation': "F1",
               '_/restart': "Shift+Alt+R",
               '_/quit': "Ctrl+Q",
               # -- In plugins/editor


Test patch:
Repository: spyder-ide/spyder

Issue:
async and await keywords highlight
## Description 

Spyder doesn't highlight **async** and **await** keywords from Python 3.5+ 

**What steps will reproduce the problem?**

1. Open spyder 
2. Enter async or await in editor

## Versions and main components

* Spyder Version: 3.0.2
* Python Version: 3.5.2
* Operating system: macOS Sierra 10.12.1

## Dependencies

```
jedi >=0.8.1     :  0.9.0 (OK)
matplotlib >=1.0 :  1.5.3 (OK)
nbconvert >=4.0  :  4.2.0 (OK)
numpy >=1.7      :  1.11.2 (OK)
pandas >=0.13.1  :  0.19.1 (OK)
pep8 >=0.6       :  1.7.0 (OK)
psutil >=0.3     :  5.0.0 (OK)
pyflakes >=0.6.0 :  1.3.0 (OK)
pygments >=2.0   :  2.1.3 (OK)
pylint >=0.25    :  1.6.4 (OK)
qtconsole >=4.2.0:  4.2.1 (OK)
rope >=0.9.4     :  0.10.3 (OK)
sphinx >=0.6.6   :  1.5a1 (OK)
sympy >=0.7.3    :  1.0 (OK)
```



Discussion:
Thanks for reporting. We'll fix this in Spyder 3.1.

@mariacamilaremolinagutierrez, this is an easy one for you, given that you've worked on highlighting of Python words in the past :-)

Resolving patch:
diff --git a/spyder/utils/syntaxhighlighters.py b/spyder/utils/syntaxhighlighters.py
--- a/spyder/utils/syntaxhighlighters.py
+++ b/spyder/utils/syntaxhighlighters.py
@@ -356,7 +356,8 @@ def get_token(self):
 class PythonSH(BaseSH):
     """Python Syntax Highlighter"""
     # Syntax highlighting rules:
-    PROG = re.compile(make_python_patterns(), re.S)
+    add_kw = ['async', 'await']
+    PROG = re.compile(make_python_patterns(additional_keywords=add_kw), re.S)
     IDPROG = re.compile(r"\s+(\w+)", re.S)
     ASPROG = re.compile(r".*?\b(as)\b")
     # Syntax highlighting states (from one text block to another):


Test patch:
Repository: spyder-ide/spyder

Issue:
Menus "File",  "Edit" and "Search" in master not available for mouse click
## Description of your problem

**What steps will reproduce the problem?**

1. Click mouse on menu item "File" or"Edit" or"Search". It does not available.

But if one click on "Source" and then move mose lleft menu items "File",  "Edit" and  "Search" are available.

## Versions and main components

* Spyder Version: 4.0.0dev0
* Python Version: Python 3.4.4amd64 (From WinPython)
* Operating system: Win10.0.14393


## Dependencies

jedi >=0.8.1     :  0.9.0 (OK)
matplotlib >=1.0 :  1.5.3 (OK)
nbconvert >=4.0  :  5.0.0 (OK)
numpy >=1.7      :  1.11.2 (OK)
pandas >=0.13.1  :  0.19.1 (OK)
pep8 >=0.6       :  1.7.0 (OK)
pyflakes >=0.6.0 :  1.3.0 (OK)
pygments >=2.0   :  2.1.3 (OK)
pylint >=0.25    :  1.6.4 (OK)
qtconsole >=4.2.0:  4.2.1 (OK)
rope >=0.9.4     :  0.9.4-1 (OK)
sphinx >=0.6.6   :  1.5.1 (OK)
sympy >=0.7.3    :  1.0 (OK)




Discussion:
Please open this bug in the WinPython issue tracker. We haven't done anything to break those menus, so it has to be a problem with WinPython.

Resolving patch:
diff --git a/spyder/app/mainwindow.py b/spyder/app/mainwindow.py
--- a/spyder/app/mainwindow.py
+++ b/spyder/app/mainwindow.py
@@ -1240,6 +1240,9 @@ def post_visible_setup(self):
         # Show dialog with missing dependencies
         self.report_missing_dependencies()
 
+        # Raise the menuBar to the top of the main window widget's stack
+        # (Fixes issue 3887)
+        self.menuBar().raise_()
         self.is_setting_up = False
 
     def update_window_title(self):


Test patch:
Repository: spyder-ide/spyder

Issue:
Profiler error when no filename is passed to it
Hello!

* Spyder Version: Git version (4dev)
* Python Version: 3.5
* Operating system: Arch Linux

When I click on Run > Profile , It produces this error:
`Traceback (most recent call last):
  File "/usr/lib/python3.5/site-packages/spyder_profiler/profiler.py", line 138, in run_profiler
    self.analyze(self.main.editor.get_current_filename())
  File "/usr/lib/python3.5/site-packages/spyder_profiler/profiler.py", line 155, in analyze
    pythonpath=pythonpath)
TypeError: analyze() got multiple values for argument 'wdir'`




Discussion:

Resolving patch:
diff --git a/spyder_profiler/profiler.py b/spyder_profiler/profiler.py
--- a/spyder_profiler/profiler.py
+++ b/spyder_profiler/profiler.py
@@ -151,5 +151,5 @@ def analyze(self, filename):
                 wdir = runconf.wdir
             if runconf.args_enabled:
                 args = runconf.args
-        self.profiler.analyze(self, filename, wdir=wdir, args=args,
+        self.profiler.analyze(filename, wdir=wdir, args=args,
                               pythonpath=pythonpath)


Test patch:
Repository: spyder-ide/spyder

Issue:
Error when executing argparse in IPython console
The following code snippet fails when it is executed with `F9` or in cell mode.

```
import argparse
parser = argparse.ArgumentParser()
args = parser.parse_args()
```

The reason is the arguments passed to the ipython console, in particular the `-f`:

```
>>> import sys
>>> print(sys.argv)
['/usr/local/lib/python3.5/dist-packages/spyder/utils/ipython/start_kernel.py', '-f', '/run/user/1000/jupyter/kernel-690215617a08.json']
```

**What steps will reproduce the problem?**

1. Run code snippet above in ipython console
2. An error message is generated

The code snippet does work when executed in the python console. It also worked with previous versions of spyder. The issue is probably the same as #1557.

## Versions and main components

* Spyder Version: Spyder 4.0.0.dev0 
* Python Version: 3.5.2
* Operating system: Ubuntu





Discussion:
What does `-f` have to do with this?
The `-f` is not one of the arguments in my `parser` object, that is why the line `args = parser.parse_args()` fails. To compare: if I run the code snippet from the command line, then the follow works:
```
python snippet.py
```
but the following fails:
```
python -f dummyvalue snippet.py
```

So the solution would be to clear `sys.argv` for our IPython consoles, right?
That would solve it for me yes. Not sure how easy that is to do in spyder. Note that if I run the code with `F5` then the arguments are cleared.
@andfoy, please work on this one. The idea is to clean `sys.argv` in `utils/ipython/start_kernel.py` by evaluating 

    import sys; sys.argv=['']; del sys

in the same way as we evaluate the matplotlib magic.

Resolving patch:
diff --git a/spyder/utils/ipython/start_kernel.py b/spyder/utils/ipython/start_kernel.py
--- a/spyder/utils/ipython/start_kernel.py
+++ b/spyder/utils/ipython/start_kernel.py
@@ -36,7 +36,7 @@ def sympy_config(mpl_backend):
 
 
 def kernel_config():
-    """Create a config object with IPython kernel options"""
+    """Create a config object with IPython kernel options."""
     from IPython.core.application import get_ipython_dir
     from traitlets.config.loader import Config, load_pyconfig_files
     if not IS_EXT_INTERPRETER:
@@ -71,6 +71,10 @@ def kernel_config():
     else:
         spy_cfg.IPKernelApp.exec_lines = []
 
+    # Clean terminal arguments input
+    clear_argv = 'import sys;sys.argv = [''];del sys'
+    spy_cfg.IPKernelApp.exec_lines.append(clear_argv)
+
     # Pylab configuration
     mpl_backend = None
     mpl_installed = is_module_installed('matplotlib')


Test patch:
Repository: spyder-ide/spyder

Issue:
Go-to-line dialog shows a question mark button that does nothing
@Usama23 reported this bug in a Continuum internal repository. I'm moving it here so we can work on it in the open. According to @Usama23:

**Actual Result:**
   Under the Go to line pop up window, click on Help icon ( ? ). button is clickable but on action perform on click.

**Expected Result**:
   When click on help icon (?), this should open Help related detail page.

![screenshot_28](https://cloud.githubusercontent.com/assets/21064099/21715079/5797d794-d424-11e6-9c7f-9ae5416e74cc.png)



Discussion:
@dalthviz, I think the solution is just to remove that question mark button. The dialog is clear enough to add some help about it :-)

Resolving patch:
diff --git a/spyder/widgets/sourcecode/codeeditor.py b/spyder/widgets/sourcecode/codeeditor.py
--- a/spyder/widgets/sourcecode/codeeditor.py
+++ b/spyder/widgets/sourcecode/codeeditor.py
@@ -81,7 +81,8 @@ def is_letter_or_number(char):
 # =============================================================================
 class GoToLineDialog(QDialog):
     def __init__(self, editor):
-        QDialog.__init__(self, editor)
+        QDialog.__init__(self, editor, Qt.WindowTitleHint
+                         | Qt.WindowCloseButtonHint)
 
         # Destroying the C++ object right after closing the dialog box,
         # otherwise it may be garbage-collected in another QThread


Test patch:
Repository: spyder-ide/spyder

Issue:
Saving a file is not respecting the encoding detected with chardet
After PR #3742, we're now detecting (and displaying) correctly files with encodings like Big5 (which is more than what Sublime and VSCode can do by default :-)

However, after doing changes to these files, Spyder is saving them as Unicode instead of respecting their encodings.

@rlaverde, please solve this one.


Discussion:

Resolving patch:
diff --git a/spyder/utils/encoding.py b/spyder/utils/encoding.py
--- a/spyder/utils/encoding.py
+++ b/spyder/utils/encoding.py
@@ -171,6 +171,13 @@ def encode(text, orig_coding):
     if orig_coding == 'utf-8-bom':
         return BOM_UTF8 + text.encode("utf-8"), 'utf-8-bom'
     
+    # Try saving with original encoding
+    if orig_coding:
+        try:
+            return text.encode(orig_coding), orig_coding
+        except UnicodeError:
+            pass
+
     # Try declared coding spec
     coding = get_coding(text)
     if coding:


Test patch:
Repository: spyder-ide/spyder

Issue:
Add verification for 'text/plain' key in all evaluations of the IPython console
We need to verify that `data` and `text/plain` exist in all `if` clauses of `handle_exec_method` (present in `widgets/ipythonconsole/shell.py`).

@dalthviz, please work on this one.

----

Please see this message for details:

https://groups.google.com/d/msg/spyderlib/UzrM0VP4sOU/Eh-JSjRPFQAJ


Discussion:

Resolving patch:
diff --git a/spyder/widgets/ipythonconsole/shell.py b/spyder/widgets/ipythonconsole/shell.py
--- a/spyder/widgets/ipythonconsole/shell.py
+++ b/spyder/widgets/ipythonconsole/shell.py
@@ -240,14 +240,17 @@ def handle_exec_method(self, msg):
                 if 'get_namespace_view' in method:
                     if data is not None and 'text/plain' in data:
                         view = ast.literal_eval(data['text/plain'])
-                        self.sig_namespace_view.emit(view)
                     else:
                         view = None
+                    self.sig_namespace_view.emit(view)
                 elif 'get_var_properties' in method:
-                    properties = ast.literal_eval(data['text/plain'])
+                    if data is not None and 'text/plain' in data:
+                        properties = ast.literal_eval(data['text/plain'])
+                    else:
+                        properties = None
                     self.sig_var_properties.emit(properties)
                 else:
-                    if data is not None:
+                    if data is not None and 'text/plain' in data:
                         self._kernel_reply = ast.literal_eval(data['text/plain'])
                     else:
                         self._kernel_reply = None
diff --git a/spyder/widgets/variableexplorer/namespacebrowser.py b/spyder/widgets/variableexplorer/namespacebrowser.py
--- a/spyder/widgets/variableexplorer/namespacebrowser.py
+++ b/spyder/widgets/variableexplorer/namespacebrowser.py
@@ -342,7 +342,8 @@ def process_remote_view(self, remote_view):
 
     def set_var_properties(self, properties):
         """Set properties of variables"""
-        self.var_properties = properties
+        if properties is not None:
+            self.var_properties = properties
 
     #------ Remote commands ------------------------------------
     def get_value(self, name):


Test patch:
Repository: spyder-ide/spyder

Issue:
File switcher doesn't leave focus in its last selected file when it looses focus
When you select a file in the File switcher and then use the mouse to give focus to the Editor or the IPython console, then the switcher doesn't leave focus in that file but instead return focus to the file that had focus when the user *first* pressed `Ctrl+P`.

This is counterintuitive and must be fixed. @andfoy, please work on it.


Discussion:

Resolving patch:
diff --git a/spyder/widgets/fileswitcher.py b/spyder/widgets/fileswitcher.py
--- a/spyder/widgets/fileswitcher.py
+++ b/spyder/widgets/fileswitcher.py
@@ -186,9 +186,7 @@ def recurse_level(level_idx):
 
 
 class KeyPressFilter(QObject):
-    """
-    Use with `installEventFilter` to get up/down arrow key press signal.
-    """
+    """Use with `installEventFilter` to get up/down arrow key press signal."""
     UP, DOWN = [-1, 1]  # Step constants
 
     sig_up_key_pressed = Signal()
@@ -204,6 +202,23 @@ def eventFilter(self, src, e):
         return super(KeyPressFilter, self).eventFilter(src, e)
 
 
+class FilesFilterLine(QLineEdit):
+    """QLineEdit used to filter files by name."""
+
+    # User has not clicked outside this widget
+    clicked_outside = False
+
+    def focusOutEvent(self, event):
+        """
+        Detect when the focus goes out of this widget.
+
+        This is used to make the file switcher leave focus on the
+        last selected file by the user.
+        """
+        self.clicked_outside = True
+        return super(QLineEdit, self).focusOutEvent(event)
+
+
 class FileSwitcher(QDialog):
     """A Sublime-like file switcher."""
     sig_goto_file = Signal(int)
@@ -240,7 +255,7 @@ def __init__(self, parent, tabs, data):
                         "([A-Za-z0-9_]{0,100}:{0,1}[0-9]{0,100})")
 
         # Widgets
-        self.edit = QLineEdit(self)
+        self.edit = FilesFilterLine(self)
         self.help = HelperToolButton()
         self.list = QListWidget(self)
         self.filter = KeyPressFilter()
@@ -346,14 +361,15 @@ def restore_initial_state(self):
         self.is_visible = False
         editors = self.editors_by_path
 
-        for path in self.initial_cursors:
-            cursor = self.initial_cursors[path]
-            if path in editors:
-                self.set_editor_cursor(editors[path], cursor)
+        if not self.edit.clicked_outside:
+            for path in self.initial_cursors:
+                cursor = self.initial_cursors[path]
+                if path in editors:
+                    self.set_editor_cursor(editors[path], cursor)
 
-        if self.initial_editor in self.paths_by_editor:
-            index = self.paths.index(self.initial_path)
-            self.sig_goto_file.emit(index)
+            if self.initial_editor in self.paths_by_editor:
+                index = self.paths.index(self.initial_path)
+                self.sig_goto_file.emit(index)
 
     def set_dialog_position(self):
         """Positions the file switcher dialog in the center of the editor."""


Test patch:
Repository: spyder-ide/spyder

Issue:
Error when deleting the file with last focus in a project
**What steps will reproduce the problem?**

1. Open a project
2. Open a  file in the project and keep focus on it
3. Close Spyder
4. Delete the file
5. Open Spyder

**What is the expected output? What do you see instead?**

the editor don't load any files, and throw this error:

```
>>> Traceback (most recent call last):
  File "/home/rlaverde/code/spyder/spyder/plugins/projects.py", line 144, in <lambda>
    lambda v: self.editor.setup_open_files())
  File "/home/rlaverde/code/spyder/spyder/plugins/editor.py", line 2635, in setup_open_files
    filenames = self.reorder_filenames(filenames)
  File "/home/rlaverde/code/spyder/spyder/plugins/editor.py", line 2667, in reorder_filenames
    index_first_file = filenames.index(cfname)
ValueError: '/home/rlaverde/code/spyder/spyder/widgets/panels/scrollflag.py' is not in list
```

The error is throw by https://github.com/spyder-ide/spyder/blob/master/spyder/plugins/editor.py#L2667

I'm not sure how this should be fixed, maybe just catch the error and don't change the focus?


Discussion:
@mariacamilaremolinagutierrez, please take a look at this one because it corresponds to the code you added in PR #3858.

Resolving patch:
diff --git a/spyder/plugins/editor.py b/spyder/plugins/editor.py
--- a/spyder/plugins/editor.py
+++ b/spyder/plugins/editor.py
@@ -2664,12 +2664,17 @@ def reorder_filenames(self, filenames):
         for index, (is_vertical, cfname, clines) in enumerate(splitsettings):
             #the first element of filenames is now the one that last had focus
             if index == 0:
-                index_first_file = filenames.index(cfname)
-                filenames.pop(index_first_file)
-                filenames.insert(0, cfname)
-            clines_0 = clines[0]
-            clines.pop(index_first_file)
-            clines.insert(0, clines_0)
+                if cfname in filenames:
+                    index_first_file = filenames.index(cfname)
+                    filenames.pop(index_first_file)
+                    filenames.insert(0, cfname)
+                else:
+                    cfname = filenames[0]
+                    index_first_file = 0
+            if index_first_file != 0:
+                clines_0 = clines[0]
+                clines.pop(index_first_file)
+                clines.insert(0, clines_0)
             reordered_splitsettings.append((is_vertical, cfname, clines))
         layout['splitsettings'] = reordered_splitsettings
         self.set_option('layout_settings', layout)


Test patch:
Repository: spyder-ide/spyder

Issue:
Remove file path from Editor's plugin title
@dalthviz, we need this to tab the Notebook next to the Editor and avoid those long strings in the Editor title when a file's path is very long.


Discussion:

Resolving patch:
diff --git a/spyder/plugins/editor.py b/spyder/plugins/editor.py
--- a/spyder/plugins/editor.py
+++ b/spyder/plugins/editor.py
@@ -542,19 +542,17 @@ def restore_scrollbar_position(self):
     def get_plugin_title(self):
         """Return widget title"""
         title = _('Editor')
-        filename = self.get_current_filename()
-        if filename:
-            title += ' - '+to_text_string(filename)
         return title
-    
+
     def get_plugin_icon(self):
-        """Return widget icon"""
+        """Return widget icon."""
         return ima.icon('edit')
     
     def get_focus_widget(self):
         """
-        Return the widget to give focus to when
-        this plugin's dockwidget is raised on top-level
+        Return the widget to give focus to.
+
+        This happens when plugin's dockwidget is raised on top-level.
         """
         return self.get_current_editor()
 


Test patch: