Open
Description
Currently completion candidates are sorted by score, and then secondarily sorted lexicographically to provide a predictable order. I propose we instead do a secondary sort by candidate length, preferring shorter candidates. My intuition is that shorter names are used more frequently than longer names, so it is a somewhat better heuristic to put shorter items first, all else being equal.
Edit: Note that this proposal only comes in to play when candidates have identical scores. Currently the tie-break sorting is alphabetical; I'm proposing we switch to a potentially better heuristic. This will have a very small impact in general.
Contrived example:
package main
type myStr struct {
s string
}
func (m myStr) Get() string {
return m.s
}
type foo struct {
ID myStr
AardvarkID myStr
}
func main() {
var f foo
var _ string = f // want "f.ID.s" but got "f.AardvarkID.s"
var _ string = fidget // want "f.ID.Get()" but got "f.AardvarkID.Get()"
}
/cc @heschik because you had an opinion in slack