Skip to content

Make TabCompletion case-insensitive for file names on Unix (2-nd attempt) - #7221

Closed
Ilya (iSazonov) wants to merge 4 commits into
PowerShell:masterfrom
iSazonov:unix-globbing-case-insensitive-2
Closed

Ilya (iSazonov) wants to merge 4 commits into
PowerShell:masterfrom
iSazonov:unix-globbing-case-insensitive-2

Conversation

@iSazonov

@iSazonov Ilya (iSazonov) commented Jul 2, 2018 •

Copy link
Copy Markdown
Collaborator

PR Summary

Attempt to fix #1273.

PR Checklist

@iSazonov
Ilya (iSazonov) force-pushed the unix-globbing-case-insensitive-2 branch from adaddb9 to 313755d Compare July 2, 2018 13:21
@iSazonov
Ilya (iSazonov) force-pushed the unix-globbing-case-insensitive-2 branch from bf9a4d5 to be262de Compare July 2, 2018 14:50
@iSazonov

Copy link
Copy Markdown
Collaborator Author

Steve Lee (@SteveL-MSFT) sergei (@vors) Can we review and merge the PR before 6.1?

Push-Location -Path $tempDir
$res = TabExpansion2 -inputScript $oneSubDirLowerTest -cursorColumn $oneSubDirLowerTest.Length
$res.CompletionMatches.Count | Should BeGreaterThan 0
$res.CompletionMatches[0].CompletionText | Should Be ".${separator}$oneSubDirTest"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I would expect the result casing to match the actual casing. Use -BeExactly

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed.

$res.CompletionMatches[0].CompletionText | Should Be ".${separator}$oneSubDirTest"

$res = TabExpansion2 -inputScript $oneSubDirUpperTest -cursorColumn $oneSubDirUpperTest.Length
$res.CompletionMatches.Count | Should BeGreaterThan 0

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Shouldn't we know exactly the number of expected completions?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

For this fix, it does not matter count (the check is only protection from exception in next line) - the order is important.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Since this test created the folder structure, the number of completions should be the same each time, right?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yes. Count check was added.


$res = TabExpansion2 -inputScript $oneSubDirUpperTest -cursorColumn $oneSubDirUpperTest.Length
$res.CompletionMatches.Count | Should BeGreaterThan 0
$res.CompletionMatches[0].CompletionText | Should Be ".${separator}$oneSubDirTest"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

-BeExactly

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed.

It "TabCompletion should be case-sensitive for file names on Unix" -Skip:(!$IsLinux) {
Push-Location -Path $tempDir
$res = TabExpansion2 -inputScript $oneSubDirLowerTest -cursorColumn $oneSubDirLowerTest.Length
$res.CompletionMatches.Count | Should BeGreaterThan 0

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Shouldn't we know exactly the number of expected completions?

Push-Location -Path $tempDir
$res = TabExpansion2 -inputScript $oneSubDirLowerTest -cursorColumn $oneSubDirLowerTest.Length
$res.CompletionMatches.Count | Should BeGreaterThan 0
$res.CompletionMatches[0].CompletionText | Should BeExactly ".${separator}$oneSubDirTest"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

-BeExactly

$res.CompletionMatches[0].CompletionText | Should BeExactly ".${separator}$oneSubDirTest"

$res = TabExpansion2 -inputScript $oneSubDirUpperTest -cursorColumn $oneSubDirUpperTest.Length
$res.CompletionMatches.Count | Should BeGreaterThan 0

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Shouldn't we know exactly how many results we should get since we control the folder structure?


$res = TabExpansion2 -inputScript $oneSubDirUpperTest -cursorColumn $oneSubDirUpperTest.Length
$res.CompletionMatches.Count | Should BeGreaterThan 0
$res.CompletionMatches[0].CompletionText | Should BeExactly ".${separator}$oneSubDirTest2"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

-BeExactly

It "TabCompletion should be case-insensitive for file names on Windows and MacOS" -Skip:($IsLinux) {
Push-Location -Path $tempDir
$res = TabExpansion2 -inputScript $oneSubDirLowerTest -cursorColumn $oneSubDirLowerTest.Length
$res.CompletionMatches.Count | Should BeGreaterThan 0

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Shouldn't we know exactly the number of expected completions?

It "TabCompletion should be case-sensitive for file names on Unix" -Skip:(!$IsLinux) {
Push-Location -Path $tempDir
$res = TabExpansion2 -inputScript $oneSubDirLowerTest -cursorColumn $oneSubDirLowerTest.Length
$res.CompletionMatches | Should -HaveCount 2

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This should still be -HaveCount 1? You're testing that "onesubd" and "oneSubD" both return "onesubdir", right?

It seems we should have a test for Linux for a directory structure like:

testfolder
testFolder

and tabcomplete off test should return two results

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This additional test case is still needed.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Steve Lee (@SteveL-MSFT) It is already there - see line 226. So I removed last commit. Seems my solution is not full - the count should be 2 on .
How can I get the artifact (compiled PowerShell) from CI Travis?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ilya (@iSazonov) you're right, I misunderstood that test. Did a little investigation and it appears that the change to GetFileSystemEntries() is not sufficient as a call to Resolve-Path earlier only returns case-sensitive matches on Linux.

@iSazonov Ilya (iSazonov) Aug 2, 2018 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Steve Lee (@SteveL-MSFT) Should we open new issue to discuss making Resolve-Path case-insensitive? This is most likely to affect globbing whole.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ilya (@iSazonov) we should probably have a new issue for Resolve-Path. May need to add a -CaseInsensitive switch to maintain backwards compatibility.

@iSazonov
Ilya (iSazonov) force-pushed the unix-globbing-case-insensitive-2 branch from e1c394b to 8e3f64e Compare August 1, 2018 04:44
@stale

stale Bot commented Sep 1, 2018

Copy link
Copy Markdown

This PR has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed if no further activity occurs within 10 days.
Thank you for your contributions.
Community members are welcome to grab these works.

@stale stale Bot added the Stale label Sep 1, 2018
@vors
sergei (vors) removed their request for review September 1, 2018 11:17
@stale stale Bot removed the Stale label Sep 1, 2018
@iSazonov

Ilya (iSazonov) commented Sep 3, 2018 •

Copy link
Copy Markdown
Collaborator Author

I considered Resolve-Path -CaseInsensitive . Adding the parameter in APIs looks as hude change in engine (in public APIs too). Another way is to introduce new internal flag/property. I like this more but don't still get full understanding of the consequences (side affects). We could use the property to be case-insensitive in some scenarios on Unix-s.

Michael Klement (@mklement0) Maybe you have any thoughts about this?

@stale

stale Bot commented Oct 3, 2018

Copy link
Copy Markdown

This PR has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed if no further activity occurs within 10 days.
Thank you for your contributions.
Community members are welcome to grab these works.

@stale stale Bot added the Stale label Oct 3, 2018
@stale

stale Bot commented Oct 13, 2018

Copy link
Copy Markdown

This PR has be automatically close because it is stale. If you wish to continue working on the PR, please first update the PR, then reopen it.
Thanks again for your contribution.
Community members are welcome to grab these works.

@stale stale Bot closed this Oct 13, 2018
@iSazonov

Copy link
Copy Markdown
Collaborator Author

The fix needs changes in some API levels. It is a lot of work...

@iSazonov
Ilya (iSazonov) deleted the unix-globbing-case-insensitive-2 branch May 15, 2020 13:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Location completion should be case-insensitive

2 participants