Skip to content

Consider supporting [extension to VT,] DECSCUSR "0" to restore cursor to user default to help vim/others #1604

Closed

Description

Environment

Windows build number: 1903
Windows Terminal version (if applicable): 0.2.1715

Any other software? neovim v0.3.4

Steps to reproduce

  • Create a profile that uses cursorShape "vintage"
  • Open nvim
  • close nvim

Expected behavior

After closing nvim I would expect to have the "vintage" cursor again.

Actual behavior

Cursor is a filledBox that doesn't blink anymore

Activity

  1. ghost added
    Needs-TriageIt's a new issue that the core contributor team needs to triage at the next triage meeting
    on Jun 25, 2019
  2. ghost added
    Needs-Tag-FixDoesn't match tag requirements
    on Jun 25, 2019
  3. egmontkob commented on Jun 25, 2019

    @egmontkob

    I'm not sure what escape sequences Windows Terminal supports for changing the cursor shape, nor what (Neo)Vim outputs, so sorry if I get it wrong.

    I assume that the DECSCUSR escape sequence is being used (see e.g. at ctlseqs.html).

    In gnome-terminal (vte) we intentionally deviate from the xterm's behavior (the behavior documented on the linked page). For parameters 1–6 we go with the given mode. However, if the parameter is 0 (or missing), we revert to whichever cursor shape the user specified as their favorite in the terminal's preferences.

    This might be a behavior for WIndows Terminal to consider, too.

  4. xtremeperf commented on Jun 27, 2019

    @xtremeperf

    This is actually intended behavior for Vim/Nvim and I can't recall any sort of "restore cursor leaving application mode" termcap that could be implemented in the terminal.

    And yes, that's correct... DECSCUSR has been implemented in WindowsTerminal for changing cursor shape (1-6).

    Vim explicitly changes the cursor shape for each of it's editing modes and it requires that you assign the ESC sequences in your vimrc file, as they are not using any sort of standard termcap variable for this.

    Vim does not change the cursor shape on exit. The cursor shape from normal mode will remain, since you must exit from normal mode.

    For more info in Vim:
    :help termcap-cursor-shape

    It's easy to change the cursor shape upon exit for yourself using an autocmd VimLeave
    :help VimLeave

    I hope that helps!

  5. jtourlamain commented on Jun 27, 2019

    @jtourlamain
    Author

    Doug (@xtremeperf) Thanks for your tip!
    Found a possible solution on neovim/neovim#4867.
    Adding au VimLeave * set guicursor=a:hor10-blinkon1 gives a blinking underscore when you exit vim

  6. egmontkob commented on Jun 27, 2019

    @egmontkob

    The DECSCUSR sequence is a poorly designed one.

    One problem is the lack of save/restore or revert, which we somewhat address in gnome-terminal by deviating from the standard. This way vim could restore the user's preferred version on exit.

    The other problem is that two orthogonal properties are tied together. For an app like vim, it really makes sense to toggle between two different shapes, while leave blinking at the user's preferred setting. It's currently not possible.

    The best solution could be to cooperate between terminal emulators and apps to come up with a better designed escape sequence. Until then, we live with the limitations, and optionally come up with hacks to mitigate the problems.

  7. DHowett-MSFT commented on Jun 27, 2019

    @DHowett-MSFT
    Contributor

    I like the idea of using a nonstandard DECSCUSR extension to reset the cursor to "user default."

  8. DHowett-MSFT commented on Jun 27, 2019

    @DHowett-MSFT
    Contributor

    I'll float that to Mike Griese (@zadjii-msft) -- if we don't want to do it, we'll close this issue as "unfortunately by design". 😄

  9. added
    Area-VTVirtual Terminal sequence support
    Issue-TaskIt's a feature request, but it doesn't really need a major design.
    Product-ConhostFor issues in the Console codebase
    and removed
    Issue-BugIt either shouldn't be doing this or needs an investigation.
    Needs-TriageIt's a new issue that the core contributor team needs to triage at the next triage meeting
    on Jun 27, 2019
  10. 21 remaining items

  11. gnachman commented on Mar 14, 2020

    @gnachman

    I'm supportive of the proposal to repurpose 0 to restore the user's default in iTerm2, which came to my attention here: https://gitlab.com/gnachman/iterm2/-/issues/8769

    I'd like to see one or two more terminals commit to this before making the change, though. I'm sure it will break some users' configurations, and it's only justifiable if it's the clear path forward.

  12. j4james commented on Mar 14, 2020

    @j4james
    Collaborator

    George Nachman (@gnachman) I've done a bit of testing on the terminals I have installed, and there are actually a few that support this extension. Other than VTE, there's also mintty and alacritty, which support both 0 and a missing parameter for selecting the user's preferred cursor. Then there is kitty (the Linux terminal, not the putty fork) which supports only 0 (a missing parameter selects the block cursor).

    I still think DECRQSS makes more sense for apps that actually want to restore the cursor shape (rather than just resetting it to a default value), but DECSCUSR 0 is not a bad fall back option.

  13. gnachman commented on Mar 14, 2020

    @gnachman

    Thanks for providing the additional context, James Holderness (@j4james) . I'm not a fan of DECRQSS for two reasons:

    1. Using it casually (like in a shell script) is too hard.
    2. Reporting in general is full of race conditions, where the reported code sometimes gets printed to the screen if the user hits a key, a program crashes, or an ssh connection ends at just the wrong moment.

    I think the strongest argument in favor of adopting this change is that 0 is the same as 1. Anyone who has problems can fix them without too much trouble. Considering VTTY, mintty, and alacritty already support it, that's strong evidence that there is a lot of hard-to-fix software in the wild.

  14. gnachman commented on May 14, 2020

    @gnachman

    FYI I've implemented DECSCUSR 0 to reset cursor style & blink in gnachman/iTerm2@5680f97

  15. ghost added
    In-PRThis issue has a related PR
    on Sep 4, 2020
  16. ghost closed this as completedin #7379on Sep 4, 2020
  17. ghost removed
    In-PRThis issue has a related PR
    on Sep 4, 2020
  18. ghost added
    Resolution-Fix-CommittedFix is checked in, but it might be 3-4 weeks until a release.
    on Sep 4, 2020
  19. DHowett commented on Oct 14, 2020

    @DHowett
    Member

    The fix for this issue was just released as part of Windows in Insider Build 20236!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-VTVirtual Terminal sequence supportHelp WantedWe encourage anyone to jump in on these.Issue-TaskIt's a feature request, but it doesn't really need a major design.Product-ConhostFor issues in the Console codebaseProduct-TerminalThe new Windows Terminal.Resolution-Fix-CommittedFix is checked in, but it might be 3-4 weeks until a release.good first issueThis is a fix that might be easier for someone to do as a first contribution

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions