mirror of
				https://github.com/cheat/cheat.git
				synced 2025-11-04 07:45:28 +01:00 
			
		
		
		
	fix(view): whitespace corrections
- Fix bug whereby `--all` flag would conflict with pager - Fix whitespace inconsistencies among view and search outputs
This commit is contained in:
		@@ -7,10 +7,15 @@ import (
 | 
			
		||||
 | 
			
		||||
// Indent prepends each line of a string with a tab
 | 
			
		||||
func Indent(str string) string {
 | 
			
		||||
 | 
			
		||||
	// trim superfluous whitespace
 | 
			
		||||
	str = strings.TrimSpace(str)
 | 
			
		||||
 | 
			
		||||
	// prepend each line with a tab character
 | 
			
		||||
	out := ""
 | 
			
		||||
	for _, line := range strings.Split(str, "\n") {
 | 
			
		||||
		out += fmt.Sprintf("\t%s\n", line)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return strings.TrimSuffix(out, "\n")
 | 
			
		||||
	return out
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -5,7 +5,7 @@ import "testing"
 | 
			
		||||
// TestIndent asserts that Indent prepends a tab to each line
 | 
			
		||||
func TestIndent(t *testing.T) {
 | 
			
		||||
	got := Indent("foo\nbar\nbaz")
 | 
			
		||||
	want := "\tfoo\n\tbar\n\tbaz"
 | 
			
		||||
	want := "\tfoo\n\tbar\n\tbaz\n"
 | 
			
		||||
	if got != want {
 | 
			
		||||
		t.Errorf("failed to indent: want: %s, got: %s", want, got)
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user