Skip to content

Operators tokens remain flagged as operators after TokenKind is changed to Generic in Command Mode #10348

Closed

Description

@msftrncs

While trying to understand why PSReadLine highlights operator tokens in command mode as operators (though they are not in that context) , I determined that the parser/tokenizer (Tokens Class) has a method that specifically resets the TokenKind of a token, to 'Generic'. However it fails to remove the flags originally set from the original TokenKind. This most commonly occurs to the operators, which in command mode, are not operators and instead are treated as unquoted arguments. PSReadLine uses the TokenFlags UnaryOperator, BinaryOperator and AssignmentOperator to highlight operators, and so that is what it sees

Steps to reproduce

echo 1 + 2 + 3 (1 + 2 + 3)
#      ^   ^ not operators
#                 ^   ^ operators!

Activity

  1. added
    Issue-Question
    on Aug 13, 2019
  2. added
    WG-Engine
    WG-Interactive-PSReadLine
    on Aug 13, 2019
  3. lzybkr commented on Aug 21, 2019

    @lzybkr
    Contributor

    I removed the Area-PSReadLine tag. The issue can only be worked around in PSReadLine, a proper fix in the PowerShell parser might help other tools as well.

  4. vexx32 commented on Aug 21, 2019

    @vexx32
    Collaborator

    Is there any behaviour that depends on the retention of the original TokenFlags values? It seems odd not to reset the flags when changing the TokenKind. 🤔

    If not, it doesn't seem like a particularly complex fix.

  5. lzybkr commented on Aug 21, 2019

    @lzybkr
    Contributor

    Clearing the "operator" token flags when changing the token kind to Generic feels safe to me.

  6. microsoft-github-policy-service commented on Nov 16, 2023

    @microsoft-github-policy-service
    Contributor

    This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.

  7. added
    Resolution-No Activity
    on Nov 16, 2023
  8. microsoft-github-policy-service commented on Nov 23, 2023

    @microsoft-github-policy-service
    Contributor

    This issue has been marked as "No Activity" as there has been no activity for 6 months. It has been closed for housekeeping purposes.

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

    Issue-QuestionResolution-No ActivityWG-Engine

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions