Trim trailing space in search results

pull/195/head
Simon Let 3 years ago
parent 48b0ec4fe2
commit 7da16a6bf6
  1. 13
      internal/searchapp/item.go

@ -362,9 +362,15 @@ func NewItemFromRecordForQuery(record recordint.SearchApp, query Query, debug bo
const timeScoreCoef = 1e-13
// nonZeroExitCodeScorePenalty + differentHostScorePenalty
// Trim trailing whitespace before highlighting
trimmedCmdLine := strings.TrimRightFunc(record.CmdLine, unicode.IsSpace)
// KEY for deduplication
key := trimmedCmdLine
score := 0.0
anyHit := false
cmd := record.CmdLine
cmd := trimmedCmdLine
for _, term := range query.terms {
c := strings.Count(record.CmdLine, term)
if c > 0 {
@ -379,12 +385,9 @@ func NewItemFromRecordForQuery(record recordint.SearchApp, query Query, debug bo
// DISPLAY > cmdline
// cmd := "<" + strings.ReplaceAll(record.CmdLine, "\n", ";") + ">"
cmdLine := strings.ReplaceAll(record.CmdLine, "\n", "\\n ")
cmdLine := strings.ReplaceAll(trimmedCmdLine, "\n", "\\n ")
cmdLineWithColor := strings.ReplaceAll(cmd, "\n", "\\n ")
// KEY for deduplication
key := strings.TrimRightFunc(record.CmdLine, unicode.IsSpace)
if record.IsRaw {
return Item{
isRaw: true,

Loading…
Cancel
Save