mirror of https://github.com/cheat/cheat.git
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.
This commit is contained in:
parent
4e9b2928b3
commit
9fa0c466fd
|
@ -55,6 +55,7 @@ func cmdSearch(opts map[string]interface{}, conf config.Config) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// sort the cheatsheets alphabetically, and search for matches
|
// sort the cheatsheets alphabetically, and search for matches
|
||||||
|
out := ""
|
||||||
for _, sheet := range sheets.Sort(consolidated) {
|
for _, sheet := range sheets.Sort(consolidated) {
|
||||||
|
|
||||||
// assume that we want to perform a case-insensitive search for <phrase>
|
// assume that we want to perform a case-insensitive search for <phrase>
|
||||||
|
@ -88,14 +89,14 @@ func cmdSearch(opts map[string]interface{}, conf config.Config) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// output the cheatsheet title
|
// 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
|
// indent each line of content with two spaces
|
||||||
for _, line := range strings.Split(sheet.Text, "\n") {
|
for _, line := range strings.Split(sheet.Text, "\n") {
|
||||||
out += fmt.Sprintf(" %s\n", line)
|
out += fmt.Sprintf(" %s\n", line)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// display the output
|
// display the output
|
||||||
display.Display(out, conf)
|
display.Display(out, conf)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ import (
|
||||||
"github.com/cheat/cheat/internal/installer"
|
"github.com/cheat/cheat/internal/installer"
|
||||||
)
|
)
|
||||||
|
|
||||||
const version = "4.0.0"
|
const version = "4.0.1"
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue