Repository: spyder-ide/spyder

Issue:
Completion before ")" causes internal problem.
## Description

### What steps will reproduce the problem?

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

Type "...method()" just inside a closing ")". 
For example: type the ".isoformat()" part inside this line:


  print(timestr, timestamp<cursor>)
  
to try and get this:

  print(timestr, timestamp.isoformat())

### Traceback
```python-traceback
  File "/Users/utting/anaconda3/envs/bus-testing/lib/python3.7/site-packages/spyder/plugins/editor/widgets/codeeditor.py", line 1134, in process_signatures
    parameter_data = parameters[parameter_idx]
IndexError: list index out of range

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/utting/anaconda3/envs/bus-testing/lib/python3.7/logging/__init__.py", line 1025, in emit
    msg = self.format(record)
  File "/Users/utting/anaconda3/envs/bus-testing/lib/python3.7/logging/__init__.py", line 869, in format
    return fmt.format(record)
  File "/Users/utting/anaconda3/envs/bus-testing/lib/python3.7/logging/__init__.py", line 608, in format
    record.message = record.getMessage()
  File "/Users/utting/anaconda3/envs/bus-testing/lib/python3.7/logging/__init__.py", line 369, in getMessage
    msg = msg % self.args
ValueError: incomplete format
Call stack:
  File "/Users/utting/anaconda3/envs/bus-testing/bin/spyder", line 11, in <module>
    sys.exit(main())
  File "/Users/utting/anaconda3/envs/bus-testing/lib/python3.7/site-packages/spyder/app/start.py", line 196, in main
    mainwindow.main()
  File "/Users/utting/anaconda3/envs/bus-testing/lib/python3.7/site-packages/spyder/app/mainwindow.py", line 3646, in main
    mainwindow = run_spyder(app, options, args)
  File "/Users/utting/anaconda3/envs/bus-testing/lib/python3.7/site-packages/spyder/app/mainwindow.py", line 3529, in run_spyder
    app.exec_()
  File "/Users/utting/anaconda3/envs/bus-testing/lib/python3.7/site-packages/spyder/plugins/completion/plugin.py", line 138, in receive_response
    self.gather_and_send(request_responses)
  File "/Users/utting/anaconda3/envs/bus-testing/lib/python3.7/site-packages/spyder/plugins/completion/plugin.py", line 189, in gather_and_send
    response_instance.handle_response(req_type, responses)
  File "/Users/utting/anaconda3/envs/bus-testing/lib/python3.7/site-packages/spyder/plugins/editor/widgets/codeeditor.py", line 915, in handle_response
    handler(params)
  File "/Users/utting/anaconda3/envs/bus-testing/lib/python3.7/site-packages/spyder/plugins/editor/widgets/codeeditor.py", line 1151, in process_signatures
    self.log_lsp_handle_errors("Error when processing signature")
  File "/Users/utting/anaconda3/envs/bus-testing/lib/python3.7/site-packages/spyder/plugins/editor/widgets/codeeditor.py", line 946, in log_lsp_handle_errors
    logger.error('%', 1, stack_info=True)
Message: '%'
Arguments: (1,)
```

## Versions

* Spyder version: 4.0.0b7 
* Python version: 3.7.0
* Qt version: 5.9.6
* PyQt5 version: 5.9.2
* Operating System: Darwin 18.7.0

### Dependencies

```
cloudpickle >=0.5.0          :  1.2.2 (OK)
pygments >=2.0               :  2.4.2 (OK)
qtconsole >=4.5.5            :  4.5.5 (OK)
nbconvert >=4.0              :  5.6.0 (OK)
sphinx >=0.6.6               :  2.2.0 (OK)
pylint >=0.25                :  2.4.2 (OK)
psutil >=0.3                 :  5.6.3 (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.5.0;<2.0.0:  1.6.0 (OK)
qdarkstyle >=2.7             :  2.7 (OK)
atomicwrites >=1.2.0         :  1.3.0 (OK)
diff_match_patch >=20181111  :  20181111 (OK)
watchdog                     :  None (OK)
keyring                      :  None (OK)
pexpect >=4.4.0              :  4.7.0 (OK)
pympler                      :  None (OK)
sympy >=0.7.3                :  None (NOK)
cython >=0.21                :  None (NOK)
IPython >=4.0                :  7.8.0 (OK)
matplotlib >=2.0.0           :  3.1.1 (OK)
pandas >=0.13.1              :  0.25.1 (OK)
numpy >=1.7                  :  1.17.2 (OK)
scipy >=0.17.0               :  1.3.1 (OK)
pyls >=0.28.2;<0.29.0        :  0.28.3 (OK)
rtree >=0.8.3                :  0.8.3 (OK)
```



Discussion:

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
@@ -1130,7 +1130,7 @@ def process_signatures(self, params):
                 parameter_idx = signature_params['activeParameter']
                 parameters = signature_data['parameters']
                 parameter = None
-                if parameter_idx < len(parameters):
+                if len(parameters) > 0 and parameter_idx < len(parameters):
                     parameter_data = parameters[parameter_idx]
                     parameter = parameter_data['label']
 


Test patch: