Skip to content

Commit 5466e05

Browse files
committed
Fixing logic for none
1 parent 8e2590b commit 5466e05

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

rasterm.go

+5-8
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,15 @@ func (typ TermType) Available() bool {
2525
if r, ok := encoders[typ]; ok {
2626
return r.Available()
2727
}
28-
return typ == None
28+
return false
2929
}
3030

3131
// Encode encodes the image to w.
3232
func (typ TermType) Encode(w io.Writer, img image.Image) error {
33-
switch r, ok := encoders[typ]; {
34-
case ok:
33+
if r, ok := encoders[typ]; ok {
3534
return r.Encode(w, img)
36-
case typ != None:
37-
return ErrTermGraphicsNotAvailable
3835
}
39-
return nil
36+
return ErrTermGraphicsNotAvailable
4037
}
4138

4239
// EnvValue returns the environment value name for the type.
@@ -76,6 +73,8 @@ func (typ TermType) MarshalText() ([]byte, error) {
7673
// UnmarshalText satisfies the [encoding.TextUnmarshaler] interface.
7774
func (typ *TermType) UnmarshalText(buf []byte) error {
7875
switch strings.ToLower(string(buf)) {
76+
default:
77+
*typ = None
7978
case "kitty":
8079
*typ = Kitty
8180
case "iterm":
@@ -84,8 +83,6 @@ func (typ *TermType) UnmarshalText(buf []byte) error {
8483
*typ = Sixel
8584
case "":
8685
*typ = Default
87-
default:
88-
*typ = None
8986
}
9087
return nil
9188
}

rasterm_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
)
1414

1515
func TestAvailable(t *testing.T) {
16-
for _, typ := range []TermType{Kitty, ITerm, Sixel, Default} {
16+
for _, typ := range []TermType{None, Kitty, ITerm, Sixel, Default} {
1717
t.Logf("type: % 7s env: % 6s available: %t", typ, typ.EnvValue(), typ.Available())
1818
}
1919
}

0 commit comments

Comments
 (0)