Skip to content

Conversation

daxian-dbw
Copy link
Member

@daxian-dbw daxian-dbw commented Jul 6, 2022

PR Summary

Fix #3334
Fix #1233

Fix ViModeIndicator = Cursor for Windows Terminal by writing out escape sequences that configure cursor shape.

PR Checklist

  • PR has a meaningful title
    • Use the present tense and imperative mood when describing your changes
  • Summarized changes
  • Make sure you've added one or more new tests
  • Make sure you've tested these changes in terminals that PowerShell is commonly used in (i.e. conhost.exe, Windows Terminal, Visual Studio Code Integrated Terminal, etc.)
  • User-facing changes
    • Not Applicable
    • OR
    • Documentation needed at PowerShell-Docs
      • Doc Issue filed:
Microsoft Reviewers: Open in CodeFlow

@daxian-dbw daxian-dbw requested a review from andyleejordan July 6, 2022 22:44
Comment on lines +50 to +54
// See the cursor ANSI codes at https://www.real-world-systems.com/docs/ANSIcode.html, searching for 'blinking block'.
// We write out the ANSI escape sequence even if we are on Windows, where the 'Console.CursorSize' API is supported by .NET.
// This is because this API works fine in console host, but not in Windows Terminal. The escape sequence will configure the
// cursor as expected in Windows Terminal, while in console host, the escape sequence works after it's written out, but then
// will be overwritten by 'CursorSize' when the user continues typing.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this mean there's a bit of a race condition where it can look unexpectedly different before the user continues typing?

Copy link
Member Author

@daxian-dbw daxian-dbw Jul 8, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There could be. The blinking underscore shape from Ansi code is thinner that "Console.CursorSize = 25" in console host, but not different too much. In Windows Terminal, there is no race condition, since we can change the cursor shape only through the Ansi sequences.

@daxian-dbw daxian-dbw merged commit fbaba3e into PowerShell:master Jul 8, 2022
@daxian-dbw daxian-dbw deleted the cursor branch July 8, 2022 22:30
@daxian-dbw
Copy link
Member Author

Thanks @andschwa for the review!

@ghost
Copy link

ghost commented Mar 8, 2023

🎉 v2.3.0-beta0 has been released which incorporates this pull request. 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

-ViModeIndicator "Cursor" option not applying correctly on Windows Terminal ViModeIndicator = Cursor does not work in Windows Terminal
2 participants