Skip to content

The extension breaks normal VS Code selection behavior in PowerShell files #5473

@alexchexes

Description

@alexchexes

Prerequisites

  • I have written a descriptive issue title.
  • I have searched all open and closed issues to ensure it has not already been reported.
  • I have read the troubleshooting guide.
  • I am sure this issue is with the extension itself and does not reproduce in a standalone PowerShell instance.
  • I have verified that I am using the latest version of Visual Studio Code and the PowerShell extension.
  • If this is a security issue, I have read the security issue reporting guidance.

Summary

This extension breaks the expected double-click-to-select and Ctrl+Shift+Arrows-to-select behavior in PowerShell files.

It appears to treat hyphenated text like foo-bar-baz as a single word for both double-click word-selection and keyboard word-wise selection, while the expected behavior observed in any other language modes (verified in C#, JavaScript and plain text) is to treat foo, bar, and baz as separate selectable segments.

The demonstration of the issue is on the screencast. The broken Ctrl+Shift+Arrows behavior is shown in the second half of the video.

PowerShell Version

PS C:\Users\Alex> $PSVersionTable; $Host

Name                           Value
----                           -----
PSVersion                      7.6.0
PSEdition                      Core
GitCommitId                    7.6.0
OS                             Microsoft Windows 10.0.26100   
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.4
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Name             : Visual Studio Code Host
Version          : 2026.1.0
InstanceId       : 5f179194-fc41-4fa9-a797-9a1e5b9854fc       
UI               : System.Management.Automation.Internal.Host 
                   .InternalHostUserInterface
CurrentCulture   : en-US
CurrentUICulture : en-US
PrivateData      : Microsoft.PowerShell.ConsoleHost+ConsoleCo
                   lorProxy
DebuggerEnabled  : True
IsRunspacePushed : False
Runspace         : System.Management.Automation.Runspaces.Loc
                   alRunspace

Visual Studio Code Version

PS C:\Windows\System32> code --version
1.116.0
560a9dba96f961efea7b1612916f89e5d5d4d679
x64

Extension Version

PS C:\Windows\System32> code --list-extensions --show-versions | Select-String powershell

ms-vscode.powershell@2026.1.0

Steps to Reproduce

  1. Open a file, set the language mode to "PowerShell", and put this content in it:
    # foo-bar-baz
    $BROKEN_SELECTION_BEHAVIOR = "foo-bar-baz"

  1. Double-click on foo, bar, or baz, either in the comment or in the assigned string.
  2. Notice that instead of a single atom like foo, bar, or baz, the entire foo-bar-baz is always selected.

  1. Place the cursor anywhere near foo or bar, for example like this: |foo-bar-baz.
  2. Try to select one atom with the keyboard by pressing Ctrl + Shift + Arrow-Right.
  3. See that instead of a single atom like foo, the whole foo-bar-baz is always selected.

Visuals

PowerToys_2026-04-15--12-09-32--812.mp4

Logs

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-BugA bug to squash.Needs: TriageMaintainer attention needed!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions