Skip to content

Panic in parse_csi_sgr_mouse #835

@Timmmm

Description

@Timmmm

If you enable pixel mouse position reporting like this:

stdout.write_all(b"\x1B[?1016h").unwrap();

Then it works fine except if you move your mouse to the top of the screen, then it can report 0, and that causes this code to panic:

    // See http://www.xfree86.org/current/ctlseqs.html#Mouse%20Tracking
    // The upper left character position on the terminal is denoted as 1,1.
    // Subtract 1 to keep it synced with cursor
    let cx = next_parsed::<u16>(&mut split)? - 1;
    let cy = next_parsed::<u16>(&mut split)? - 1;

Because 0 - 1 underflows. Simple hack: use saturating subtract. I suspect nobody is going to care about the difference between pixel 0 and 1.

OS
Linux

Terminal/Console
Kitty

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions