Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop trying to de-duplicate completion results #3897

Merged
merged 1 commit into from
Dec 11, 2023

Conversation

daxian-dbw
Copy link
Member

@daxian-dbw daxian-dbw commented Dec 11, 2023

PR Summary

Fix #3896
Given that both ISE and VSCode editor completion doesn't de-duplicate completion results, we probably should stop trying to de-duplicate completion results in PSReadLine to be consistent.

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 merged commit f2207f4 into PowerShell:master Dec 11, 2023
1 check passed
@daxian-dbw daxian-dbw deleted the de-dup branch December 11, 2023 18:44
@blaisemGH
Copy link

I noticed on the latest master branch that I am ending up with a lot of duplicates in a particular scenario. Specifically, when I try to tab complete a function from a module that has not been imported yet.

An easy reproducible example is to type Get-PSre and hit tab. Assuming you have not imported PowerShellGet, you should end up with multiple entries for Get-PSRepository. In a couple of my modules that export more functions, I can end up with dozens of entries as each exported function appears 4-6 times.

I am not sure if it's related to this particular commit or not, but it seems suspicious. On 2.3.5 I don't have this bug.

Should I raise a separate issue on this topic?

@daxian-dbw
Copy link
Member Author

@blaisemGH Can you check if those duplicate results are also present when using intellisense in VSCode editor?

@blaisemGH
Copy link

blaisemGH commented Jun 14, 2024

@blaisemGH Can you check if those duplicate results are also present when using intellisense in VSCode editor?

@daxian-dbw Yes, the duplicates are also there in the latest version:

image

PowerShellGet has not been imported, so its exported functions seem to be duplicated.

The extension terminal is running PS7.4.2

@blaisemGH
Copy link

blaisemGH commented Jun 14, 2024

@daxian-dbw

Actually I just tested it again, and I seem to have made a mistake with my earlier statement that it began with 2.4.0. The issue existed already in PSReadLine 2.3.5:

image

However, it seems to have not existed in PSReadLine 2.3.4:

image

But the completion.cs file is the same across these versions, so I guess it's not related to this commit. Nevermind, it is this. For some reason the module 2.3.5 download from PSGallery is not the same as the Tag v2.3.5 in github—the latter shows that completion.cs still has the dedup logic, even though it doesn't (see next comment).

@blaisemGH
Copy link

blaisemGH commented Jun 14, 2024

@daxian-dbw Ok I just cloned the github tag v2.3.5, and tried building it with and without the changes in this commit. The duplicates are removed with the deduplication logic; with this commit's changes (removing the deduplication logic), the duplicates are present.

So I guess the code removed in this commit was covering up the duplicates.

@MartinGC94
Copy link

I have a fix for this in the tab completion code here: PowerShell/PowerShell#21113 though that obviously won't help older PS versions.
IMO the deduplication in PSReadLine was annoying because it was based on the list item text so if I for example tried to complete [File<Ctrl+Space> I would end up with just [System.Net.WebRequestMethods+File] when I was actually looking for [System.IO.File] so if you must bring it back then please use the actual completion text this time.

@blaisemGH
Copy link

blaisemGH commented Jun 14, 2024

Oh nice. I was digging through the tabexpansion2 source too, but glad to know there's already a PR on it. Also on my machine, it does seem to be caused by multiple available module versions and each being prepended with the module name.

I didn't know the deduplication code in PSReadLine was causing issues, but at any rate, even without that I can understand why this is the wrong place to resolve an upstream error.

Thanks for the feedback here.

@daxian-dbw
Copy link
Member Author

Yeah, the deduplication was problematic and the reason to remove it is to get consistency as in VSCode editor (not terminal) and ISE. @MartinGC94 Thanks for the PR! I will make sure review it (and maybe merge it :)) on Monday.

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.

MenuComplete filtering duplicates when it shouldn't be
3 participants