From 7faf216f9e0f1a34f8fea3a28f87b0fbcc1fea87 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 18 Sep 2023 20:59:47 +0530 Subject: [PATCH] More linter fixes --- kittens/themes/ui.go | 6 +++--- tools/tui/loop/mouse.go | 4 +++- tools/utils/images/loading.go | 15 +++++++++------ 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/kittens/themes/ui.go b/kittens/themes/ui.go index 5e7328839..9d331c5e8 100644 --- a/kittens/themes/ui.go +++ b/kittens/themes/ui.go @@ -447,10 +447,10 @@ func (self *handler) draw_theme_demo() { if intense { s = "bright-" + s } - if len(c) > trunc { - c = c[:trunc] + if len(s) > trunc { + s = s[:trunc] } - buf.WriteString(self.lp.SprintStyled("fg="+c, c)) + buf.WriteString(self.lp.SprintStyled("fg="+s, s)) buf.WriteString(" ") } text := strings.TrimSpace(buf.String()) diff --git a/tools/tui/loop/mouse.go b/tools/tui/loop/mouse.go index 775928973..2beb0a421 100644 --- a/tools/tui/loop/mouse.go +++ b/tools/tui/loop/mouse.go @@ -128,7 +128,9 @@ func decode_sgr_mouse(text string, screen_size ScreenSize) *MouseEvent { if len(parts[2]) < 1 { return nil } - ans.Pixel.Y, err = strconv.Atoi(parts[2]) + if ans.Pixel.Y, err = strconv.Atoi(parts[2]); err != nil { + return nil + } if last_letter == 'm' { ans.Event_type = MOUSE_RELEASE } else if cb&MOTION_INDICATOR != 0 { diff --git a/tools/utils/images/loading.go b/tools/utils/images/loading.go index 9d3ad37f9..32cbf39bd 100644 --- a/tools/utils/images/loading.go +++ b/tools/utils/images/loading.go @@ -324,8 +324,9 @@ func parse_identify_record(ans *IdentifyRecord, raw *IdentifyOutput) (err error) if found { ans.Canvas.Left, err = strconv.Atoi(x) if err == nil { - ans.Canvas.Top, err = strconv.Atoi(y) - ok = true + if ans.Canvas.Top, err = strconv.Atoi(y); err == nil { + ok = true + } } } } @@ -340,8 +341,9 @@ func parse_identify_record(ans *IdentifyRecord, raw *IdentifyOutput) (err error) if found { ans.Width, err = strconv.Atoi(w) if err == nil { - ans.Height, err = strconv.Atoi(h) - ok = true + if ans.Height, err = strconv.Atoi(h); err == nil { + ok = true + } } } if !ok { @@ -352,8 +354,9 @@ func parse_identify_record(ans *IdentifyRecord, raw *IdentifyOutput) (err error) if found { ans.Dpi.X, err = strconv.ParseFloat(x, 64) if err == nil { - ans.Dpi.Y, err = strconv.ParseFloat(y, 64) - ok = true + if ans.Dpi.Y, err = strconv.ParseFloat(y, 64); err == nil { + ok = true + } } } if !ok {