Skip to content

Mouse tracking is incorrectly disabled on exit #3876

@jakebailey

Description

@jakebailey

Describe the bug

When the CLI exits, my terminal can't scroll with the mouse anymore.

I used copilot to diagnose itself (yay).

The problem appears to be that while the CLI turns on mouse tracking:

 ESC[?1049h   alt screen on
 ESC[?1002h   mouse button-event tracking on
 ESC[?1006h   SGR mouse mode on

The way it turns off leaves my terminal emulator (foot) in a bad place where it cannot scroll anymore:

 ESC[?1049l   alt screen off
 ESC[?2004l
 ESC[?1004l
 ESC[?1006l   mouse off
 ESC[?1003l
 ESC[?1002l

I'm pretty sure that these events need to be done in a stack order, where the alt screen is turned off last because it was turned on first.

This appears to be a regression in 1.0.49-2 and above.

Affected version

1.0.63

Steps to reproduce the behavior

  1. Run copilot CLI
  2. Get enough text to need to scroll
  3. Test scrolling; it works
  4. Ctrl+D to exit
  5. Run git log
  6. Try to scroll it

Expected behavior

My terminal can still scroll.

Additional context

  • Terminal emulator: foot
  • Shell: zsh

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:input-keyboardKeyboard shortcuts, keybindings, copy/paste, clipboard, mouse, and text inputarea:terminal-renderingDisplay and rendering: flickering, scrolling, line wrapping, output formatting

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions