Repository: spyder-ide/spyder

Issue:
Text written in Help pane gets automatically selected after match
<!--- **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

* Searched the [issues page](https://github.com/spyder-ide/spyder/issues?q=is%3Aissue) for similar reports
All the related issues were `resolved`
* Read the relevant sections of the [Spyder Troubleshooting Guide](https://github.com/spyder-ide/spyder/wiki/Troubleshooting-Guide-and-FAQ) and followed its advice
* Reproduced the issue after updating with ``conda update spyder`` (or ``pip``, if not using Anaconda)
* Tried basic troubleshooting (if a bug/error)
    * Restarted Spyder
    * Reset preferences with ``spyder --reset``
    * Tried the other applicable steps from the Troubleshooting Guide
* Completed the **Problem Description**, **Steps to Reproduce** and **Version** sections below


## Problem Description
When typing a query into the help pane's "Object" Field, the content is selected as soon as it matches an object.  
Further typing overwrites what was entered before.

This is extremely annoying and hinders me from using the Help Pane well.

I would ask to change this behaviour or make it elective.

### What steps reproduce the problem?

1. open the Help Pane and select the "Object" text box.
2. begin to type `list.append`

### What is the expected output? What do you see instead?
`list` is being overwritten as soon as the next character is typed because list was selected automatically.

I would prefer the behaviour to be able to enter `list.append` unhindered. 

## Versions
* Spyder version: 4.0.0b2
* Python version: Python 3.6.8 64-bit
* Qt version: Qt 5.12.3
* PyQt version: PyQt5 5.12.2
* Operating System name/version: Fedora 28 (Linux 5.0.16-100.fc28.x86_64)

### Dependencies
pygments >=2.0     :  2.4.2 (OK)
qdarkstyle >=2.6.4 :  2.7 (OK)
sphinx >=0.6.6     :  2.1.0 (OK)
psutil >=0.3       :  5.6.2 (OK)
pyls >=0.19.0;<0.25:  0.24.0 (OK)
nbconvert >=4.0    :  5.5.0 (OK)
pandas >=0.13.1    :  0.22.0 (OK)
numpy >=1.7        :  1.14.5 (OK)
sympy >=0.7.3      :  1.2 (OK)
cython >=0.21      :  None (NOK)
qtconsole >=4.2.0  :  4.5.1 (OK)
IPython >=4.0      :  7.5.0 (OK)
matplotlib >=2.0.0 :  2.2.3 (OK)
pylint >=0.25      :  2.3.1 (OK)


Discussion:
Thanks for reporting, I understand what you mean.

@dalthviz, the idea is to avoid selecting the text whose docstring is going to be displayed in the Help pane.

So right now, if you write `numpy` then `numpy` gets selected and you have to move the cursor to the end to keep writing `numpy.sin` (for instance). 

![Help Pane](https://user-images.githubusercontent.com/32204163/59209023-ade9e980-8baa-11e9-907f-8be7824ae39b.gif)
Yes.

Resolving patch:
diff --git a/spyder/plugins/help/widgets.py b/spyder/plugins/help/widgets.py
--- a/spyder/plugins/help/widgets.py
+++ b/spyder/plugins/help/widgets.py
@@ -87,6 +87,8 @@ def validate(self, qstr, editing=True):
                 # A new item has just been selected
                 if valid:
                     self.selected()
+                    # See spyder-ide/spyder#9542
+                    self.lineEdit().cursorWordForward(False)
                 else:
                     self.valid.emit(False, False)
 


Test patch:
diff --git a/spyder/app/tests/test_mainwindow.py b/spyder/app/tests/test_mainwindow.py
--- a/spyder/app/tests/test_mainwindow.py
+++ b/spyder/app/tests/test_mainwindow.py
@@ -335,20 +335,21 @@ def test_get_help_combo(main_window, qtbot):
     qtbot.waitUntil(lambda: check_text(webpage, "NumPy"), timeout=6000)
 
     # Get help - numpy.arange
-    qtbot.keyClick(help_plugin.combo, Qt.Key_Right)
     qtbot.keyClicks(help_plugin.combo, '.arange', delay=100)
 
     # Check that a expected text is part of the page
     qtbot.waitUntil(lambda: check_text(webpage, "arange"), timeout=6000)
 
     # Get help - np
+    # Clear combo
+    help_plugin.combo.set_current_text('')
+
     qtbot.keyClicks(help_plugin.combo, 'np', delay=100)
 
     # Check that a expected text is part of the page
     qtbot.waitUntil(lambda: check_text(webpage, "NumPy"), timeout=6000)
 
     # Get help - np.arange
-    qtbot.keyClick(help_plugin.combo, Qt.Key_Right)
     qtbot.keyClicks(help_plugin.combo, '.arange', delay=100)
 
     # Check that a expected text is part of the page