fix(tools): avoid predeclared max names
This commit is contained in:
1 parent
6329b336fe
commit
25699ca154
3 files changed
+8
-8
No files matched your search
@@ -470,10 +470,10 @@ func TestWriteSpillSanitisesToolName(t *testing.T) {
|
||||
func TestCapPayloadKeepsRunesIntact(t *testing.T) {
|
||||
payload := strings.Repeat("é", 100) // 2 bytes per rune
|
||||
|
||||
for max := 1; max <= 20; max++ {
|
||||
got := CapPayload("read", payload, max, nil)
|
||||
for limit := 1; limit <= 20; limit++ {
|
||||
got := CapPayload("read", payload, limit, nil)
|
||||
if !utf8.ValidString(got) {
|
||||
t.Errorf("max=%d: CapPayload() returned invalid UTF-8: %q", max, got)
|
||||
t.Errorf("limit=%d: CapPayload() returned invalid UTF-8: %q", limit, got)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -316,8 +316,8 @@ func capGrepResult(output string, limit int) Result {
|
||||
|
||||
// truncationBoundary returns the largest cut point <= max that does not split
|
||||
// a UTF-8 rune.
|
||||
func truncationBoundary(s string, max int) int {
|
||||
cut := max
|
||||
func truncationBoundary(s string, limit int) int {
|
||||
cut := limit
|
||||
for cut > 0 && !utf8.RuneStart(s[cut]) {
|
||||
cut--
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ package tools
|
||||
//
|
||||
// JSON numbers decode as float64, but a model that emits an integer through
|
||||
// a different provider path can arrive as int, so both are accepted.
|
||||
func ListLimit(input map[string]any, def, max int) int {
|
||||
func ListLimit(input map[string]any, def, maxLimit int) int {
|
||||
var limit int
|
||||
switch v := input["limit"].(type) {
|
||||
case float64:
|
||||
@@ -16,8 +16,8 @@ func ListLimit(input map[string]any, def, max int) int {
|
||||
if limit <= 0 {
|
||||
return def
|
||||
}
|
||||
if limit > max {
|
||||
return max
|
||||
if limit > maxLimit {
|
||||
return maxLimit
|
||||
}
|
||||
return limit
|
||||
}
|
||||
Reference in new issue
Block a user