kovidgoyal/kitty · error

Malformed Cursor Position Report from terminal with no ;

Error message

Malformed Cursor Position Report from terminal with no ;

What it means

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.

Source

Thrown at tools/cli/wcswidth_kitten.go:29

	"github.com/kovidgoyal/kitty"
	"github.com/kovidgoyal/kitty/tools/tty"
	"github.com/kovidgoyal/kitty/tools/tui/loop"
	"github.com/kovidgoyal/kitty/tools/utils"
	"github.com/kovidgoyal/kitty/tools/utils/style"
	"github.com/kovidgoyal/kitty/tools/wcswidth"
)

var _ = fmt.Print

type cpos struct {
	x, y int
}

func cpos_from_report(csi string) (ans cpos, err error) {
	before, after, found := strings.Cut(csi, ";")
	if !found {
		return ans, fmt.Errorf("Malformed Cursor Position Report from terminal with no ;")
	}
	if ans.y, err = strconv.Atoi(before); err != nil {
		return ans, fmt.Errorf("Malformed Cursor Position Report from terminal: %s", csi)
	}
	if ans.x, err = strconv.Atoi(after); err != nil {
		return ans, fmt.Errorf("Malformed Cursor Position Report from terminal: %s", csi)
	}
	// convert 1-based indexing to zero based indexing
	ans.x--
	ans.y--
	return
}

type test_struct struct {
	description               string
	num                       int
	expected_cursor_positions []int
	actual_cursor_positions   []cpos

View on GitHub (pinned to 6d5d0c4406)

Solutions

  1. Run the kitten in a conformant terminal directly, without tmux/screen wrapping
  2. Make sure no other process is reading from the same tty while the kitten runs
  3. Update kitty (the kitten and kitty itself must be from the same version)
  4. If your emulator truly lacks CPR support, skip this diagnostic kitten
Defensive patterns

Strategy: validation

Validate before calling

func validCPR(s string) bool {
    _, _, ok := strings.Cut(s, ";")
    return ok
}

Try / catch

if _, err := cpos_from_report(csi); err != nil {
    log.Printf("ignoring malformed CPR %q: %v", csi, err)
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Related errors


AI-assisted analysis of kovidgoyal/kitty@6d5d0c4406 (2026-08-27). Data as JSON: /api/errors/08a1648bf0ba40fb. Report an issue: GitHub.