Skip to content

Commit

Permalink
style: empty default for path
Browse files Browse the repository at this point in the history
  • Loading branch information
rsteube committed Jan 26, 2024
1 parent a481597 commit d1cfdfe
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 30 deletions.
58 changes: 29 additions & 29 deletions action_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,39 +116,39 @@ func TestNoSpace(t *testing.T) {
func TestActionDirectories(t *testing.T) {
assertEqual(t,
ActionStyledValues(
"example/", style.Of("fg-default", "bg-default", style.Blue, style.Bold),
"example-nonposix/", style.Of("fg-default", "bg-default", style.Blue, style.Bold),
"docs/", style.Of("fg-default", "bg-default", style.Blue, style.Bold),
"internal/", style.Of("fg-default", "bg-default", style.Blue, style.Bold),
"pkg/", style.Of("fg-default", "bg-default", style.Blue, style.Bold),
"third_party/", style.Of("fg-default", "bg-default", style.Blue, style.Bold),
"example/", style.Of(style.Blue, style.Bold),
"example-nonposix/", style.Of(style.Blue, style.Bold),
"docs/", style.Of(style.Blue, style.Bold),
"internal/", style.Of(style.Blue, style.Bold),
"pkg/", style.Of(style.Blue, style.Bold),
"third_party/", style.Of(style.Blue, style.Bold),
).NoSpace('/').Tag("directories").Invoke(Context{}),
ActionDirectories().Invoke(Context{Value: ""}).Filter("vendor/"),
)

assertEqual(t,
ActionStyledValues(
"example/", style.Of("fg-default", "bg-default", style.Blue, style.Bold),
"example-nonposix/", style.Of("fg-default", "bg-default", style.Blue, style.Bold),
"docs/", style.Of("fg-default", "bg-default", style.Blue, style.Bold),
"internal/", style.Of("fg-default", "bg-default", style.Blue, style.Bold),
"pkg/", style.Of("fg-default", "bg-default", style.Blue, style.Bold),
"third_party/", style.Of("fg-default", "bg-default", style.Blue, style.Bold),
"example/", style.Of(style.Blue, style.Bold),
"example-nonposix/", style.Of(style.Blue, style.Bold),
"docs/", style.Of(style.Blue, style.Bold),
"internal/", style.Of(style.Blue, style.Bold),
"pkg/", style.Of(style.Blue, style.Bold),
"third_party/", style.Of(style.Blue, style.Bold),
).NoSpace('/').Tag("directories").Invoke(Context{}).Prefix("./"),
ActionDirectories().Invoke(Context{Value: "./"}).Filter("./vendor/"),
)

assertEqual(t,
ActionStyledValues(
"_test/", style.Of("fg-default", "bg-default", style.Blue, style.Bold),
"cmd/", style.Of("fg-default", "bg-default", style.Blue, style.Bold),
"_test/", style.Of(style.Blue, style.Bold),
"cmd/", style.Of(style.Blue, style.Bold),
).NoSpace('/').Tag("directories").Invoke(Context{}).Prefix("example/"),
ActionDirectories().Invoke(Context{Value: "example/"}),
)

assertEqual(t,
ActionStyledValues(
"cmd/", style.Of("fg-default", "bg-default", style.Blue, style.Bold),
"cmd/", style.Of(style.Blue, style.Bold),
).NoSpace('/').Tag("directories").Invoke(Context{}).Prefix("example/"),
ActionDirectories().Invoke(Context{Value: "example/cm"}),
)
Expand All @@ -157,24 +157,24 @@ func TestActionDirectories(t *testing.T) {
func TestActionFiles(t *testing.T) {
assertEqual(t,
ActionStyledValues(
"README.md", style.Of("fg-default", "bg-default"),
"example/", style.Of("fg-default", "bg-default", style.Blue, style.Bold),
"example-nonposix/", style.Of("fg-default", "bg-default", style.Blue, style.Bold),
"docs/", style.Of("fg-default", "bg-default", style.Blue, style.Bold),
"internal/", style.Of("fg-default", "bg-default", style.Blue, style.Bold),
"pkg/", style.Of("fg-default", "bg-default", style.Blue, style.Bold),
"third_party/", style.Of("fg-default", "bg-default", style.Blue, style.Bold),
"README.md", style.Default,
"example/", style.Of(style.Blue, style.Bold),
"example-nonposix/", style.Of(style.Blue, style.Bold),
"docs/", style.Of(style.Blue, style.Bold),
"internal/", style.Of(style.Blue, style.Bold),
"pkg/", style.Of(style.Blue, style.Bold),
"third_party/", style.Of(style.Blue, style.Bold),
).NoSpace('/').Tag("files").Invoke(Context{}),
ActionFiles(".md").Invoke(Context{Value: ""}).Filter("vendor/"),
)

assertEqual(t,
ActionStyledValues(
"README.md", style.Of("fg-default", "bg-default"),
"_test/", style.Of("fg-default", "bg-default", style.Blue, style.Bold),
"cmd/", style.Of("fg-default", "bg-default", style.Blue, style.Bold),
"main.go", style.Of("fg-default", "bg-default"),
"main_test.go", style.Of("fg-default", "bg-default"),
"README.md", style.Default,
"_test/", style.Of(style.Blue, style.Bold),
"cmd/", style.Of(style.Blue, style.Bold),
"main.go", style.Default,
"main_test.go", style.Default,
).NoSpace('/').Tag("files").Invoke(Context{}).Prefix("example/"),
ActionFiles().Invoke(Context{Value: "example/"}).Filter("example/example"),
)
Expand All @@ -195,8 +195,8 @@ func TestActionFilesChdir(t *testing.T) {

assertEqual(t,
ActionStyledValues(
"action.go", style.Of("fg-default", "bg-default"),
"snippet.go", style.Of("fg-default", "bg-default"),
"action.go", style.Default,
"snippet.go", style.Default,
).NoSpace('/').Tag("files").Invoke(Context{}).Prefix("elvish/"),
ActionFiles().Chdir("internal/shell").Invoke(Context{Value: "elvish/"}),
)
Expand Down
2 changes: 1 addition & 1 deletion pkg/style/path.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func ForPathExt(path string, sc Context) string {

func fromSGR(sgr string) string {
s := ui.StyleFromSGR(sgr)
result := []string{"fg-default", "bg-default"}
result := []string{}
if s.Foreground != nil {
result = append(result, s.Foreground.String())
}
Expand Down

0 comments on commit d1cfdfe

Please sign in to comment.