Skip to content

Commit

Permalink
cmd/zoekt: trim '\n' from match (#867)
Browse files Browse the repository at this point in the history
Before, we'd typically have two newlines, one coming from the corpus,
and one terminating the fmt.Printf call.
  • Loading branch information
hanwen-flow authored Nov 28, 2024
1 parent 87a0b74 commit 333dfef
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion cmd/zoekt/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package main

import (
"bytes"
"context"
"flag"
"fmt"
Expand Down Expand Up @@ -44,7 +45,8 @@ func displayMatches(files []zoekt.FileMatch, pat string, withRepo bool, list boo
}

for _, m := range f.LineMatches {
fmt.Printf("%s%s:%d:%s%s\n", r, f.FileName, m.LineNumber, m.Line, addTabIfNonEmpty(f.Debug))
l := bytes.TrimSuffix(m.Line, []byte{'\n'})
fmt.Printf("%s%s:%d:%s%s\n", r, f.FileName, m.LineNumber, l, addTabIfNonEmpty(f.Debug))
}
}
}
Expand Down

0 comments on commit 333dfef

Please sign in to comment.