DamnWidget/anaconda — pull request #176 by rahul-ramadas (2014-07-04 23:58:38+00:00)
Title: Weird autocomplete behavior with function parameters

For the following Python code:

```python
def foo(fizz, buzz):
pass

foo(f
```

the completions I get when I type `f` are the following:

![completions](https://cloud.githubusercontent.com/assets/2167984/3485283/302da290-03d1-11e4-8ea2-8099c1c470f9.png)

As you can see, I get two instances of `fizz`. I specified `suppress_word_completions` as `true`, so it is not due to that. The problem with the first one (the one that is not marked as `param`) is that if I select it and commit it using tab, the text gets selected. This is annoying because if I keep typing, it will overwrite the text.

![committed](https://cloud.githubusercontent.com/assets/2167984/3485298/ba73b2f0-03d1-11e4-9da3-0d32e7308d65.png)

This doesn't happen if I select the `param` entry.

I dug into the code a little bit and it looks like this is because Anaconda composes the autocomplete list from two things: [the completions as returned by Jedi](https://github.com/DamnWidget/anaconda/blob/master/anaconda_server/commands/autocomplete.py#L27), and the [parameters for the current function call](https://github.com/DamnWidget/anaconda/blob/master/anaconda_server/commands/autocomplete.py#L26) (if applicable). However, it looks like Jedi already returns the parameters when you request the completions, so maybe the additional logic to add parameters is unnecessary.