{"record":{"id":"08a1648bf0ba40fb","repo":"kovidgoyal/kitty","slug":"malformed-cursor-position-report-from-terminal-wit","errorCode":null,"errorMessage":"Malformed Cursor Position Report from terminal with no ;","messagePattern":"Malformed Cursor Position Report from terminal with no ;","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"tools/cli/wcswidth_kitten.go","lineNumber":29,"sourceCode":"\n\t\"github.com/kovidgoyal/kitty\"\n\t\"github.com/kovidgoyal/kitty/tools/tty\"\n\t\"github.com/kovidgoyal/kitty/tools/tui/loop\"\n\t\"github.com/kovidgoyal/kitty/tools/utils\"\n\t\"github.com/kovidgoyal/kitty/tools/utils/style\"\n\t\"github.com/kovidgoyal/kitty/tools/wcswidth\"\n)\n\nvar _ = fmt.Print\n\ntype cpos struct {\n\tx, y int\n}\n\nfunc cpos_from_report(csi string) (ans cpos, err error) {\n\tbefore, after, found := strings.Cut(csi, \";\")\n\tif !found {\n\t\treturn ans, fmt.Errorf(\"Malformed Cursor Position Report from terminal with no ;\")\n\t}\n\tif ans.y, err = strconv.Atoi(before); err != nil {\n\t\treturn ans, fmt.Errorf(\"Malformed Cursor Position Report from terminal: %s\", csi)\n\t}\n\tif ans.x, err = strconv.Atoi(after); err != nil {\n\t\treturn ans, fmt.Errorf(\"Malformed Cursor Position Report from terminal: %s\", csi)\n\t}\n\t// convert 1-based indexing to zero based indexing\n\tans.x--\n\tans.y--\n\treturn\n}\n\ntype test_struct struct {\n\tdescription               string\n\tnum                       int\n\texpected_cursor_positions []int\n\tactual_cursor_positions   []cpos","sourceCodeStart":11,"sourceCodeEnd":47,"githubUrl":"https://github.com/kovidgoyal/kitty/blob/6d5d0c440603ad9bdf6dcd599f73f6dde21acb44/tools/cli/wcswidth_kitten.go#L11-L47","documentation":"The wcswidth kitten sent a Device Attributes/Cursor Position Report (CPR) query to the terminal and received a CSI response that does not contain the expected ';' separator between the row and column numbers. The kitten cannot parse the terminal's cursor position report, so its width tests cannot run.","triggerScenarios":"Calling cpos_from_report with a CSI string like \"\\x1b[10;5R\" is normal; the error fires when the report string (after stripping CSI prefix) has no ';', e.g. \"\\x1b[5R\" or garbage/interference on the terminal input stream.","commonSituations":"Running the wcswidth kitten inside a terminal emulator that answers CPR non-conformantly, a multiplexer (tmux/screen) mangling the report, another program reading the tty and consuming part of the response, or a terminal that simply does not support CPR.","solutions":["Run the kitten in a conformant terminal directly, without tmux/screen wrapping","Make sure no other process is reading from the same tty while the kitten runs","Update kitty (the kitten and kitty itself must be from the same version)","If your emulator truly lacks CPR support, skip this diagnostic kitten"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"func validCPR(s string) bool {\n    _, _, ok := strings.Cut(s, \";\")\n    return ok\n}","typeGuard":null,"tryCatchPattern":"if _, err := cpos_from_report(csi); err != nil {\n    log.Printf(\"ignoring malformed CPR %q: %v\", csi, err)\n}","preventionTips":["Only query CPR on terminals that advertise support","Read the tty exclusively while awaiting reports","Strip the full CSI prefix before parsing"],"tags":["kitty","terminal","cpr","parsing"],"backgroundTag":"terminal-escape-sequence-parse-error","analyzedSha":"6d5d0c440603ad9bdf6dcd599f73f6dde21acb44","analyzedAt":"2026-08-27T14:20:20.142Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}