Эх сурвалжийг харах

Stripped excess newlines from tui

arianagiroux 3 долоо хоног өмнө
parent
commit
e910c7dac3
4 өөрчлөгдсөн 7 нэмэгдсэн , 11 устгасан
  1. 0 1
      Readme.md
  2. 2 4
      issue.go
  3. 2 2
      issue_test.go
  4. 3 4
      tui.go

+ 0 - 1
Readme.md

@@ -17,7 +17,6 @@ go install cmd/issues.go
 - `cmd/issues.go:// TODO implement interface for browse bugs in folder`
 - `io.go:func WriteIssue(issue Issue) (success bool, err error) { return false, nil } // TODO: implement`
 - `io.go:func DeleteIssue(issue Issue) (success bool, err error) { return false, nil } // TODO: implement`
-- `issue.go:// TODO strip last newline from [issues.Issue] [issues.Field] and [issues.VariadicField]`
 
 ## See also
 

+ 2 - 4
issue.go

@@ -1,6 +1,4 @@
 // Data and interface definitions for bugs
-//
-// TODO strip last newline from [issues.Issue] [issues.Field] and [issues.VariadicField]
 package issues
 
 import (
@@ -47,7 +45,7 @@ func (i Issue) NewFromPath(path string) (bug Issue, err error) {
 			return Issue{}, err
 		}
 
-		field.Data = data
+		field.Data = strings.TrimRight(data, "\n")
 	}
 
 	// Variadic Fields
@@ -116,7 +114,7 @@ func (vf VariadicField) NewFromPath(pathOnDisk string) (v VariadicField, err err
 			continue
 		}
 
-		vf.Fields = append(vf.Fields, Field{Data: data, Path: file.Name()})
+		vf.Fields = append(vf.Fields, Field{Data: strings.TrimRight(data, "\n"), Path: file.Name()})
 	}
 
 	return vf, err

+ 2 - 2
issue_test.go

@@ -46,8 +46,8 @@ func Test_Issue_NewFromPath_err_bad_path(t *testing.T) {
 func Test_Issue_NewFromPath_success(t *testing.T) {
 	testIssue := Issue{
 		Title:       "test 1",
-		Description: Field{Data: "test description\n", Path: "/description"},
-		Status:      Field{Data: "open:test\n", Path: "/status"},
+		Description: Field{Data: "test description", Path: "/description"},
+		Status:      Field{Data: "open:test", Path: "/status"},
 		Path:        "tests/bugs/test-1",
 
 		Tags: VariadicField{

+ 3 - 4
tui.go

@@ -46,7 +46,7 @@ var (
 				BorderStyle(lipgloss.ASCIIBorder())
 
 	borderStyle = lipgloss.NewStyle().
-			Padding(2).
+			Padding(1, 2).
 			Margin(1).
 			BorderStyle(lipgloss.NormalBorder())
 )
@@ -71,7 +71,7 @@ func (m Model) renderIssue() string {
 	}
 
 	if len(m.Issue.Tags.Fields) > 0 {
-		output = output + variadicTitleStyle.Render("\nTags:")
+		output = output + variadicTitleStyle.Render("\n\nTags:")
 		output = output + fmt.Sprintf("\n%s", variadicDataStyle.Render(tags))
 	}
 
@@ -81,8 +81,7 @@ func (m Model) renderIssue() string {
 	}
 
 	// description
-	output = output + "\n---"
-	output = output + titleStyle.Render("\nDescription:")
+	output = output + titleStyle.Render("\n\nDescription:\n")
 	output = output + fmt.Sprintf("\n%s", m.Issue.Description.Data)
 
 	return borderStyle.Render(output)