Bump go version to 1.21

Allows us to use the much faster builtin min/max functions
for two variable min/max
This commit is contained in:
Kovid Goyal
2023-08-09 11:58:16 +05:30
parent f125ffe3e0
commit 49ea26968c
17 changed files with 44 additions and 53 deletions

View File

@@ -57,7 +57,7 @@ func truncate_at_space(text string, width int) (string, string) {
}
func extra_for(width, screen_width int) int {
return utils.Max(0, screen_width-width)/2 + 1
return max(0, screen_width-width)/2 + 1
}
func GetChoices(o *Options) (response string, err error) {
@@ -71,7 +71,7 @@ func GetChoices(o *Options) (response string, err error) {
prefix_style_pat := regexp.MustCompile("^(?:\x1b\\[[^m]*?m)+")
choice_order := make([]Choice, 0, len(o.Choices))
clickable_ranges := make(map[string][]Range, 16)
allowed := utils.NewSet[string](utils.Max(2, len(o.Choices)))
allowed := utils.NewSet[string](max(2, len(o.Choices)))
response_on_accept := o.Default
switch o.Type {
case "yesno":
@@ -328,7 +328,7 @@ func GetChoices(o *Options) (response string, err error) {
}
}
y := int(sz.HeightCells) - len(msg_lines)
y = utils.Max(0, (y/2)-2)
y = max(0, (y/2)-2)
lp.QueueWriteString(strings.Repeat("\r\n", y))
for _, line := range msg_lines {
if replacement_text != "" {

View File

@@ -397,8 +397,8 @@ func mark(r *regexp2.Regexp, post_processors []PostProcessorFunc, group_processo
if idx > 0 && g.IsNamed {
c := g.LastCapture()
if s, e := c.Byte_Offsets.Start, c.Byte_Offsets.End; s > -1 && e > -1 {
s = utils.Max(s, match_start)
e = utils.Min(e, match_end)
s = max(s, match_start)
e = min(e, match_end)
gd[g.Name] = sanitize_pat.ReplaceAllLiteralString(text[s:e], "")
}
}
@@ -413,8 +413,8 @@ func mark(r *regexp2.Regexp, post_processors []PostProcessorFunc, group_processo
if opts.Type == "regex" && len(m.Groups) > 1 && !m.HasNamedGroups() {
cp := m.Groups[1].LastCapture()
ms, me := cp.Byte_Offsets.Start, cp.Byte_Offsets.End
match_start = utils.Max(match_start, ms)
match_end = utils.Min(match_end, me)
match_start = max(match_start, ms)
match_end = min(match_end, me)
full_match = sanitize_pat.ReplaceAllLiteralString(text[match_start:match_end], "")
}
if full_match != "" {
@@ -576,7 +576,7 @@ process_answer:
return "", nil, nil, &ErrNoMatches{Type: opts.Type}
}
largest_index := ans[len(ans)-1].Index
offset := utils.Max(0, opts.HintsOffset)
offset := max(0, opts.HintsOffset)
index_map = make(map[int]*Mark, len(ans))
for i := range ans {
m := &ans[i]