Skip to content

type completion overwrites type name with member if accessor appears after cursor #10529

Closed

Description

@msftrncs

Steps to reproduce

[convert]:: #locate cursor over `]` and press <CTRL-SPACE>

Expected behavior

Show completions for the type(s) beginning with convert

Actual behavior

Instead of offering completions for convert (to which there might not be any), it instead replaces convert with the first member of [convert], DBNull.

[DBNull]::

Environment data

Name                           Value
----                           -----
PSVersion                      7.0.0-preview.3
PSEdition                      Core
GitCommitId                    7.0.0-preview.3
OS                             Microsoft Windows 10.0.18362
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

This does appear to happen all the way back to Windows PowerShell 5.1 (on the above listed Windows 10 system).


I might try to debug in to this later. It would seem to me that the completion logic is missing the fact that the cursor position is still inside the 'type' reference and so it should be completing the type reference, not the member accessor that follows it.

Interestingly enough, VS Code (the PowerShell extension uses the completions from a PowerShell session) doesn't seem to have this issue, probably because the extension uses its own logic to determine what its actually completing. (incomplete comparison, when put in the same situation, VS Code offers no completions at all)

Activity

  1. added
    Issue-Question
    on Sep 12, 2019
  2. added
    Issue-Bug
    and removed
    Issue-Question
    on Sep 13, 2019
  3. iSazonov commented on Sep 13, 2019

    @iSazonov
    Collaborator

    I can confirm.

  4. msftrncs commented on Sep 13, 2019

    @msftrncs
    ContributorAuthor

    So far, I have determined that this only happens when the expression near the cursor results in a 'MemberExpressionAst', and the expression results in an error ('ErrorExpressionAst') due to the member expression not being complete, and the token at the cursor is a TokenKind Identifier.

    I have found other scenarios where this occurs, such as:

    $psversiontable.pscompatibleversions. # put cursor before last . and press <CTRL-SPACE>

    Result is (with a menu of array members)

    $psversiontable.Count.
  5. ghost added
    In-PR
    on Nov 22, 2021
  6. ghost removed
    In-PR
    on Mar 24, 2022
  7. ghost added
    Resolution-Fixed
    on Mar 24, 2022
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-BugResolution-FixedWG-Interactive-IntelliSense

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions