diff --git a/client/updateView.go b/client/updateView.go index e9e63de..a83b545 100644 --- a/client/updateView.go +++ b/client/updateView.go @@ -16,14 +16,14 @@ func UpdateBuffSearchView(inputTable *tview.Table, m fuzzy.Matches, f []FileNode } else { for k, v := range m { if len(f[v.Index].Children) != 0 { - inputTable.SetCell(k, 0, tview.NewTableCell(utils.GetMatchedString(v.MatchedIndexes, f[v.Index].Path, "[#0000ff:-:bi]")). + inputTable.SetCell(k, 0, tview.NewTableCell(utils.GetMatchedString(utils.Unique(v.MatchedIndexes), f[v.Index].Path, "[#0000ff:-:bi]")). SetAlign(tview.AlignLeft). SetStyle(tcell.StyleDefault. Foreground(tcell.ColorYellow). Background(tcell.ColorBlack). Bold(true))) } else { - inputTable.SetCell(k, 0, tview.NewTableCell(utils.GetMatchedString(v.MatchedIndexes, f[v.Index].Title, "[#fbff00:-:bi]")). + inputTable.SetCell(k, 0, tview.NewTableCell(utils.GetMatchedString(utils.Unique(v.MatchedIndexes), f[v.Index].Title, "[#fbff00:-:bi]")). SetAlign(tview.AlignLeft). SetStyle(tcell.StyleDefault. Foreground(tcell.ColorGreen). diff --git a/utils/utils.go b/utils/utils.go index dc18e7f..79ab01d 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -169,3 +169,15 @@ func GetMatchedString(a []int, s, color string) string { } return s } + +func Unique(intSlice []int) []int { + keys := make(map[int]bool) + list := []int{} + for _, entry := range intSlice { + if _, exists := keys[entry]; !exists { + keys[entry] = true + list = append(list, entry) + } + } + return list +}