fixed bug when triggering autocomplete whith trailing characters in line

* improved sorting for partial autocomplete matches
* added finddecl function to python wrapper