-
-
Notifications
You must be signed in to change notification settings - Fork 809
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
Quote tab completion items with PS special chars. #413
Conversation
If we merge this for 0.7.0, don't forget to update CHANGELOG.md. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Off to a good start! Seems close enough to include in this next release.
src/GitTabExpansion.ps1
Outdated
@@ -51,6 +51,15 @@ catch { | |||
Write-Debug "Search for 'flow' in 'git help' output failed with error: $_" | |||
} | |||
|
|||
filter quoteStringWithSpecialChars { | |||
if ($_ -and ($_ -match '\s+|#|@|\$|;|\{|\}|\(|\)')) { | |||
"'" + $_ + "'" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Why not
"'$_'"
? - We should also handle values that include
'
.
src/GitTabExpansion.ps1
Outdated
@@ -51,6 +51,15 @@ catch { | |||
Write-Debug "Search for 'flow' in 'git help' output failed with error: $_" | |||
} | |||
|
|||
filter quoteStringWithSpecialChars { | |||
if ($_ -and ($_ -match '\s+|#|@|\$|;|\{|\}|\(|\)')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing ,
$result | Should BeExactly $fileName | ||
} | ||
} | ||
|
||
Context 'PowerShell Special Chars Tests' { | ||
BeforeAll { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is bound to be a pretty common pattern. Is it possible to write a Pester helper that would encapsulate a BeforeAll
/AfterAll
pairing that initializes and cleans up a Git repo, with its path left in $repoPath
? Something like:
Context 'Awesome test' {
TempRepo {
# Set up the repo
}
It 'Uses $repoPath' {
# ...
}
}
I don't know that Pester will support a user-defined construct to encapuslate BeforeAll/AfterAll. But I did pull the guts out into shared functions.
I think I've addressed all of the issues except the last one the Pester helper. That said, I did move common code into reusable functions (in Shared.ps1). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Fix #293