-
Notifications
You must be signed in to change notification settings - Fork 298
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
ArgumentOutOfRangeException: Completion of Splat, but Not $ #983
Comments
I'm also pretty sure there is some code somewhere else dealing specifically with the |
Also reported at PowerShell/PowerShell#10243 |
I think the error is here: PSReadLine/PSReadLine/Completion.cs Lines 102 to 114 in b7b8f7b
The |
Do not adjust userCompletionText while finding userCompletion text position when match contains `{` in CompletionText[1], and preserve the splat sigil at start of completions of type `Variable`. Adjusting userCompletionText led to selection box consuming sigil for braced variables, or crash on incorrectly braced splats.
@msftrncs I cannot repro the crash with these steps. I'm using |
@daxian-dbw, yes, the buffer needs enough lines visible so that the list can populate without the input line scrolling off the top, so that the first item in the list can replace the current input. |
Thanks, that helps. I can repro the issue now. |
I think I forgot to include that oops, guess it doesn't, that works... |
Prevent adjustment of userCompletionText while finding userCompletion text position when match contains `{` in CompletionText[1] if the userCompletionText is not longer than 1 char, and preserve the splat sigil at start of completions of type `Variable`. Adjusting userCompletionText blindly led to ArgumentOutOfRangeException on incorrectly braced splats on input `@?`.
I think I figured out what the check for a The detection for a |
@msftrncs I can reproduce the crash using
The selection looks fine to me for variables that require a brace. Can you please clarify it a bit more? |
Hopefully these snips clarify the comment, but because it could be said better: 'the selection of the leading Because the |
Thanks for the further clarification. You really have a pair of sharp eyes to find this inconsistency 😄 |
Using a custom build of PS 7 Preview, but also applies to 5.1 and 6/6.1/6.2 in the right conditions.
I have been working with the PowerShell code to try to get completion starting at a splat
@
to work. With that working, the current completion code completes the$
variable as@{$}
, which is knowingly invalid, and it causes an ArgumentOutOfRange exception.Steps to reproduce or exception report
This reproduction is for the released builds of PowerShell, as they will not currently produce completions for just a
@
argument.Complete the following:
Note, the window must be large enough as to be able to display the entire list without the input line scrolling off the top. Also, I've only tested this in Windows.
Code in Question
I traced down the code that is calling the exception:
PSReadLine/PSReadLine/Completion.cs
Lines 732 to 737 in b7b8f7b
I think the check for a
{
is incorrect here, and that there is no reason to ever substring the original text, removing the prefix, which causes the completion to look like its replacing the prefix as well.The text was updated successfully, but these errors were encountered: