Another place where [:max_length] is used without checking

This commit is contained in:
Kovid Goyal 2023-04-07 18:08:38 +05:30
parent 3f943998c6
commit d9d2e31318
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -599,7 +599,10 @@ func run_loop(opts *Options) (lp *loop.Loop, err error) {
if idx > -1 { if idx > -1 {
cached_data.Recent = slices.Delete(cached_data.Recent, idx, idx+1) cached_data.Recent = slices.Delete(cached_data.Recent, idx, idx+1)
} }
cached_data.Recent = slices.Insert(cached_data.Recent, 0, h.current_char)[:len(DEFAULT_SET)] cached_data.Recent = slices.Insert(cached_data.Recent, 0, h.current_char)
if len(cached_data.Recent) > len(DEFAULT_SET) {
cached_data.Recent = cached_data.Recent[:len(DEFAULT_SET)]
}
ans := h.resolved_char() ans := h.resolved_char()
o, err := output(ans) o, err := output(ans)
if err != nil { if err != nil {