mirror of
https://github.com/cheat/cheat.git
synced 2025-09-04 02:58:29 +02:00
fix: escape sequences in search output (#687)
Fix an issue whereby ANSI escape characters could appear in search output when a pager was not configured. The root cause of the problem was code that was overzealously applying an underlying effect to search terms. This commit simply rips out underlying entirely, both as means of resolving this problem, and also simply for removing needless visual noise from search output.
This commit is contained in:
@ -1,8 +0,0 @@
|
||||
package display
|
||||
|
||||
import "fmt"
|
||||
|
||||
// Underline returns an underlined string
|
||||
func Underline(str string) string {
|
||||
return fmt.Sprintf("\033[4m%s\033[0m", str)
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
package display
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
// TestUnderline asserts that Underline applies underline formatting
|
||||
func TestUnderline(t *testing.T) {
|
||||
want := "\033[4mfoo\033[0m"
|
||||
got := Underline("foo")
|
||||
if want != got {
|
||||
t.Errorf("failed to underline: want: %s, got: %s", want, got)
|
||||
}
|
||||
}
|
@ -23,14 +23,13 @@ func Write(out string, conf config.Config) {
|
||||
pager := parts[0]
|
||||
args := parts[1:]
|
||||
|
||||
// run the pager
|
||||
// configure the pager
|
||||
cmd := exec.Command(pager, args...)
|
||||
cmd.Stdin = strings.NewReader(out)
|
||||
cmd.Stdout = os.Stdout
|
||||
|
||||
// handle errors
|
||||
err := cmd.Run()
|
||||
if err != nil {
|
||||
// run the pager and handle errors
|
||||
if err := cmd.Run(); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "failed to write to pager: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
Reference in New Issue
Block a user