{"record":{"id":"417bb694916cd574","repo":"go-delve/delve","slug":"d-is-out-of-range","errorCode":null,"errorMessage":"%d is out of range","messagePattern":"(.+?) is out of range","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/terminal/terminal.go","lineNumber":640,"sourceCode":"\tfull := proc.LoadFullValue()\n\tr := *api.LoadConfigFromProc(&full)\n\n\tif t.conf != nil && t.conf.MaxStringLen != nil {\n\t\tr.MaxStringLen = *t.conf.MaxStringLen\n\t}\n\tif t.conf != nil && t.conf.MaxArrayValues != nil {\n\t\tr.MaxArrayValues = *t.conf.MaxArrayValues\n\t}\n\tif t.conf != nil && t.conf.MaxVariableRecurse != nil {\n\t\tr.MaxVariableRecurse = *t.conf.MaxVariableRecurse\n\t}\n\n\treturn r\n}\n\nfunc (t *Term) removeDisplay(n int) error {\n\tif n < 0 || n >= len(t.displays) {\n\t\treturn fmt.Errorf(\"%d is out of range\", n)\n\t}\n\tt.displays[n] = displayEntry{\"\", \"\"}\n\tfor i := len(t.displays) - 1; i >= 0; i-- {\n\t\tif t.displays[i].expr != \"\" {\n\t\t\tt.displays = t.displays[:i+1]\n\t\t\treturn nil\n\t\t}\n\t}\n\tt.displays = t.displays[:0]\n\treturn nil\n}\n\nfunc (t *Term) addDisplay(expr, fmtstr string) {\n\tt.displays = append(t.displays, displayEntry{expr: expr, fmtstr: fmtstr})\n}\n\n// rawStringFlag returns the PrettyRawString flag if the config enables it.\nfunc (t *Term) rawStringFlag() api.PrettyFlags {","sourceCodeStart":622,"sourceCodeEnd":658,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/pkg/terminal/terminal.go#L622-L658","documentation":"`Term.removeDisplay` deletes an entry from the term's list of `display` expressions. The index `n` must be a valid zero-based index into `t.displays`; if it is negative or past the end, the function returns '%d is out of range'. Note that removing the last non-empty entry shrinks the slice, so indices of previously-removed-but-trailing entries become invalid.","triggerScenarios":"Running the terminal `display -r <index>` command with an index that does not exist (e.g. `display -r 5` when fewer than 6 displays are defined) or a negative index.","commonSituations":"Users referring to display numbers from earlier output after some displays were removed; off-by-one confusion (thinking displays are numbered from 1); scripts replaying stale display indices.","solutions":["Run `display` with no arguments to list existing displays and their valid indices, then retry with one of those","Use an index between 0 and len(displays)-1","Remove all displays with `display -r *` if you want to clear them instead of guessing indices"],"exampleFix":"# before\ndisplay -r 5\n# after\n# list first, then remove a valid index\ndisplay\ndisplay -r 2","handlingStrategy":"validation","validationCode":"// before calling removeDisplay / `display -r n`\nfunc validDisplayIndex(n, len int) bool { return n >= 0 && n < len }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["List displays first (run `display` with no args) and use only listed indices","Remember indices are 0-based and the list compacts after removals","After any removal, refetch the list rather than reusing cached indices"],"tags":["terminal","display","index-out-of-range"],"backgroundTag":"index-out-of-range","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T22:30:34.772Z"}