Exemple #1
0
func TestSort(t *testing.T) {
	expect := expect.New(t)

	v := []string{
		"SomeLongThing",
		"Something",
		"Thing",
		"thing",
		"thisIsBad",
		"thingimajigger",
		"thingy",
		"thisIsNotAGoodMatch",
		"Thang",
		"tang",
		"bacon",
		"eggs",
	}
	expect(scoring.Sort(v, "thing")).To.Equal([]string{
		"thing",
		"Thing",
		"thingy",
		"thingimajigger",
		"Thang",
		"tang",
		"thisIsBad",
		"thisIsNotAGoodMatch",
		"Something",
		"SomeLongThing",
	})
}
Exemple #2
0
func (f *FSLocator) updateCompletions() {
	f.clearCompletions()
	f.completions = nil
	newCompletions := scoring.Sort(f.files, f.file.Text())
	for _, comp := range newCompletions {
		color := f.theme.LabelStyle.FontColor
		if strings.HasSuffix(comp, "/") {
			color = dirColor
		}
		l := newCompletionLabel(f.theme, color)
		l.SetText(comp)
		f.completions = append(f.completions, l)
	}
	f.addCompletions()
}