Trim spaces when comparing commands for duplicates to fix #26

This commit is contained in:
David Dworken 2022-11-11 10:54:00 -05:00
parent afd336c248
commit be0a61a7ea
No known key found for this signature in database
2 changed files with 2 additions and 2 deletions

View File

@ -475,7 +475,7 @@ func DisplayResults(ctx *context.Context, results []*data.HistoryEntry, numResul
lastCommand := ""
numRows := 0
for _, entry := range results {
if entry != nil && entry.Command == lastCommand && config.FilterDuplicateCommands {
if entry != nil && strings.TrimSpace(entry.Command) == strings.TrimSpace(lastCommand) && config.FilterDuplicateCommands {
continue
}
row, err := buildTableRow(ctx, config.DisplayedColumns, *entry)

View File

@ -222,7 +222,7 @@ func getRows(ctx *context.Context, columnNames []string, query string, numEntrie
for i := 0; i < numEntries; i++ {
if i < len(data) {
entry := data[i]
if entry.Command == lastCommand && config.FilterDuplicateCommands {
if strings.TrimSpace(entry.Command) == strings.TrimSpace(lastCommand) && config.FilterDuplicateCommands {
continue
}
entry.Command = strings.ReplaceAll(entry.Command, "\n", " ") // TODO: handle multi-line commands better here