Repository: spyder-ide/spyder

Issue:
Code style warnings are not updated in the Editor after "Delete line" shortcut
<!--- **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

When deleting a line, code style warning analysis is not updated.

![image](https://user-images.githubusercontent.com/10170372/57405119-a00c0780-71ab-11e9-928e-4c2bfd06e948.png)

### What steps reproduce the problem?

1. Write the following code in the Editor :
```python
def some_function():
    pass



def some_other_function():
    pass

```
This will result in a E303 code style warning.

2. Delete the extra blank line with the "Delete line" shortcut.
3. The warning does not go away.

### What is the expected output? What do you see instead?

The code style warnings should be updated after deleting a line.

## 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.0.dev0 
* Python version: Python 3.7.1 64-bit
* Qt version: Qt 5.9.6
* PyQt version: PyQt5 5.9.2
* Operating System name/version: Windows 10


Discussion:

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
@@ -1015,7 +1015,7 @@ def extend_selection_to_complete_lines(self):
         self.setTextCursor(cursor)
 
     def delete_line(self):
-        """Delete current line"""
+        """Delete current line."""
         cursor = self.textCursor()
         if self.has_selected_text():
             self.extend_selection_to_complete_lines()
@@ -1034,6 +1034,7 @@ def delete_line(self):
         cursor.removeSelectedText()
         cursor.endEditBlock()
         self.ensureCursorVisible()
+        self.document_did_change()
 
     def set_selection(self, start, end):
         cursor = self.textCursor()


Test patch:
diff --git a/spyder/plugins/editor/widgets/tests/test_warnings.py b/spyder/plugins/editor/widgets/tests/test_warnings.py
--- a/spyder/plugins/editor/widgets/tests/test_warnings.py
+++ b/spyder/plugins/editor/widgets/tests/test_warnings.py
@@ -144,3 +144,32 @@ def test_get_warnings(qtbot, lsp_codeeditor):
                 ["undefined name 's'", 5]]
 
     assert warnings == expected
+
+
+def test_update_warnings_after_delete_line(qtbot, lsp_codeeditor):
+    """
+    Test that code style warnings are correctly updated after deleting a line
+    in the Editor.
+
+    Regression test for #9299.
+    """
+    editor, _ = lsp_codeeditor
+    editor.set_text(TEXT)
+
+    # Notify changes.
+    with qtbot.waitSignal(editor.lsp_response_signal, timeout=30000):
+        editor.document_did_change()
+
+    # Delete the blank line that is causing the W293 warning on line 2.
+    editor.go_to_line(2)
+    editor.delete_line()
+
+    # Wait for the lsp_response_signal.
+    qtbot.waitSignal(editor.lsp_response_signal, timeout=30000)
+
+    # Assert that the W293 warning is gone.
+    expected = [['D100: Missing docstring in public module', 1],
+                ['D103: Missing docstring in public function', 1],
+                ['E261 at least two spaces before inline comment', 2],
+                ["undefined name 's'", 4]]
+    assert editor.get_current_warnings() == expected