From 9fa0c466fd969b0f466a68fc06d8b8c1df3fec2b Mon Sep 17 00:00:00 2001 From: Chris Lane Date: Tue, 30 Jun 2020 07:21:21 -0400 Subject: [PATCH] fix(search): fix pagination error Fix the paginator when used in combination with the `-s` (search) subcommand. Previously, it would not behave as intended, because `cheat` was writing to `stdout` at inappropriate times. --- cmd/cheat/cmd_search.go | 9 +++++---- cmd/cheat/main.go | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/cmd/cheat/cmd_search.go b/cmd/cheat/cmd_search.go index 3606b88..5ac1aa8 100644 --- a/cmd/cheat/cmd_search.go +++ b/cmd/cheat/cmd_search.go @@ -55,6 +55,7 @@ func cmdSearch(opts map[string]interface{}, conf config.Config) { } // sort the cheatsheets alphabetically, and search for matches + out := "" for _, sheet := range sheets.Sort(consolidated) { // assume that we want to perform a case-insensitive search for @@ -88,14 +89,14 @@ func cmdSearch(opts map[string]interface{}, conf config.Config) { } // output the cheatsheet title - out := fmt.Sprintf("%s:\n", sheet.Title) + out += fmt.Sprintf("%s:\n", sheet.Title) // indent each line of content with two spaces for _, line := range strings.Split(sheet.Text, "\n") { out += fmt.Sprintf(" %s\n", line) } - - // display the output - display.Display(out, conf) } + + // display the output + display.Display(out, conf) } diff --git a/cmd/cheat/main.go b/cmd/cheat/main.go index 966b7ac..f910032 100755 --- a/cmd/cheat/main.go +++ b/cmd/cheat/main.go @@ -17,7 +17,7 @@ import ( "github.com/cheat/cheat/internal/installer" ) -const version = "4.0.0" +const version = "4.0.1" func main() {