Skip to content

Conversation

@dkaszews
Copy link
Contributor

@dkaszews dkaszews commented Oct 22, 2022

PR Summary

Fixes #3455

Remove case-insensitive comparator from suggestion deduplication logic. Unnecessary ToArray() removed in neighboring line to improve performance.

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

@dkaszews
Copy link
Contributor Author

dkaszews commented Oct 22, 2022

Can I get some help with tests? I wrote a quick failing test with Assert.Equal(true, false);, but running ./build.ps1 -Test all I'm getting is:

Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
No test matches the given testcase filter `FullyQualifiedName~Test.en_US_Linux`

@daxian-dbw daxian-dbw force-pushed the dkaszews-case-sensitive-files branch from 99ef5ec to 75a9787 Compare October 24, 2022 18:28
@daxian-dbw
Copy link
Member

The ToArray() cannot be removed without changing how the filtering is done, because you cannot delete items from a collection while enumerating it.

I updated the code to get rid of ToArray(), as well as merging this fix with #3454.

Copy link
Member

@daxian-dbw daxian-dbw left a comment

Choose a reason for hiding this comment

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

LGTM

@daxian-dbw daxian-dbw self-assigned this Oct 24, 2022
@daxian-dbw daxian-dbw merged commit 4bfc4e9 into PowerShell:master Oct 24, 2022
@dkaszews
Copy link
Contributor Author

The ToArray() cannot be removed without changing how the filtering is done, because you cannot delete items from a collection while enumerating it.

Good catch, thanks. There is a better pattern to do it on the fly though:

for (int i = 0; i < collection.Length; i++) {
    if (predicate(collection[i])) {
        // postdec cancels out increment, so next loop still uses same index
        collection.RemoveAt(i--);
    }
}

I personally like it as it's compact and efficient, other people find it hacky. Up to you.

@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.

Tab completion doesn't show files whose names differ from others by case only

2 participants