Title: CompleteInput fails when passed an empty string/AST · Issue #5743 · PowerShell/PowerShell · GitHub
Open Graph Title: CompleteInput fails when passed an empty string/AST · Issue #5743 · PowerShell/PowerShell
X Title: CompleteInput fails when passed an empty string/AST · Issue #5743 · PowerShell/PowerShell
Description: Steps to reproduce [System.Management.Automation.CommandCompletion]::CompleteInput('', 0, @{}) Or [System.Management.Automation.CommandCompletion]::CompleteInput( {}.Ast, @(), {}.Ast.Extent.StartScriptPosition, @{}) Expected behavior Cur...
Open Graph Description: Steps to reproduce [System.Management.Automation.CommandCompletion]::CompleteInput('', 0, @{}) Or [System.Management.Automation.CommandCompletion]::CompleteInput( {}.Ast, @(), {}.Ast.Extent.StartSc...
X Description: Steps to reproduce [System.Management.Automation.CommandCompletion]::CompleteInput('', 0, @{}) Or [System.Management.Automation.CommandCompletion]::CompleteInput( {}.Ast, @(), {}.Ast.Extent...
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/5743
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"CompleteInput fails when passed an empty string/AST","articleBody":"\u003c!--\r\n\r\nFor Windows PowerShell 5.1 issues, suggestions, or feature requests please use the following link instead:\r\n- Windows PowerShell [UserVoice](https://windowsserver.uservoice.com/forums/301869-powershell)\r\n\r\nIf it is a bug report:\r\n- make sure you are able to repro it on the latest released version. \r\nYou can install the latest version from https://github.com/PowerShell/PowerShell/releases\r\n- Search the existing issues.\r\n- Refer to the [FAQ](https://github.com/PowerShell/PowerShell/blob/master/docs/FAQ.md).\r\n- Refer to the [known issues](https://github.com/PowerShell/PowerShell/blob/master/docs/KNOWNISSUES.md).\r\n- Fill out the following repro template:\r\n\r\nIf it's not a bug, please remove the template and elaborate the issue in your own words.\r\n--\u003e\r\n\r\nSteps to reproduce\r\n------------------\r\n\r\n```powershell\r\n[System.Management.Automation.CommandCompletion]::CompleteInput('', 0, @{})\r\n```\r\n\r\nOr\r\n\r\n```powershell\r\n[System.Management.Automation.CommandCompletion]::CompleteInput(\r\n\t{}.Ast,\r\n\t@(),\r\n\t{}.Ast.Extent.StartScriptPosition,\r\n\t@{})\r\n```\r\n\r\nExpected behavior\r\n-----------------\r\n\r\n```none\r\nCurrentMatchIndex ReplacementIndex ReplacementLength CompletionMatches\r\n----------------- ---------------- ----------------- -----------------\r\n -1 0 0 {}\r\n```\r\n\r\nAlternatively if throwing is a design choice, throw an `ArgumentException` instead of letting `Enumerable.Last` fail.\r\n\r\nActual behavior\r\n---------------\r\n\r\n```none\r\n\u003e [System.Management.Automation.CommandCompletion]::CompleteInput('', 0, @{})\r\nException calling \"CompleteInput\" with \"3\" argument(s): \"Sequence contains no elements\"\r\nAt line:1 char:1\r\n+ [System.Management.Automation.CommandCompletion]::CompleteInput('', 0 ...\r\n+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException\r\n+ FullyQualifiedErrorId : InvalidOperationException\r\n\r\n\u003e $Error[0].Exception.InnerException | Format-List * -Force\r\nMessage : Sequence contains no elements\r\nData : {}\r\nInnerException :\r\nTargetSite : TSource Last[TSource](System.Collections.Generic.IEnumerable`1[TSource])\r\nStackTrace : at System.Linq.Enumerable.Last[TSource](IEnumerable`1 source)\r\n at\r\n System.Management.Automation.CompletionAnalysis.InitializeCompletionContext(TypeInferenceContext\r\n typeInferenceContext)\r\n at System.Management.Automation.CompletionAnalysis.GetResults(PowerShell powerShell, Int32\u0026\r\n replacementIndex, Int32\u0026 replacementLength)\r\n at System.Management.Automation.CommandCompletion.CompleteInputImpl(Ast ast, Token[] tokens,\r\n IScriptPosition positionOfCursor, Hashtable options)\r\n at System.Management.Automation.CommandCompletion.CompleteInput(String input, Int32 cursorIndex,\r\n Hashtable options)\r\n at CallSite.Target(Closure , CallSite , Type , String , Int32 , Hashtable )\r\nHelpLink :\r\nSource : System.Linq\r\nHResult : -2146233079\r\n```\r\n\r\nEnvironment data\r\n----------------\r\n\r\n\u003c!-- provide the output of $PSVersionTable --\u003e\r\n\r\n```powershell\r\n\u003e $PSVersionTable\r\nName Value\r\n---- -----\r\nPSVersion 6.0.0-rc.2\r\nPSEdition Core\r\nGitCommitId v6.0.0-rc.2\r\nOS Microsoft Windows 10.0.15063\r\nPlatform Win32NT\r\nPSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}\r\nPSRemotingProtocolVersion 2.3\r\nSerializationVersion 1.1.0.1\r\nWSManStackVersion 3.0\r\n```\r\n","author":{"url":"https://github.com/SeeminglyScience","@type":"Person","name":"SeeminglyScience"},"datePublished":"2017-12-24T20:46:53.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/5743/PowerShell/issues/5743"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:e3365c21-6b6c-ecab-d1d3-98871aa48271 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DAF0:97027:D7DB3:12D972:6A546495 |
| html-safe-nonce | 67710563f5282f58b86d6ddbb58d268425119f5d3abf73f4f8b6b96515e421ec |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEQUYwOjk3MDI3OkQ3REIzOjEyRDk3Mjo2QTU0NjQ5NSIsInZpc2l0b3JfaWQiOiIxMzEyMDkyNTMwNTI0MDU0Njc4IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | eaf61192aba1a0a303d4511e4f60e24300a2dbf7dc54311c42870379bce81374 |
| hovercard-subject-tag | issue:284381585 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/PowerShell/PowerShell/5743/issue_layout |
| twitter:image | https://opengraph.githubassets.com/3a7244fc90774f47d140d112fee59e88704ca904113450e5bf422ae8ee5a5df9/PowerShell/PowerShell/issues/5743 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/3a7244fc90774f47d140d112fee59e88704ca904113450e5bf422ae8ee5a5df9/PowerShell/PowerShell/issues/5743 |
| og:image:alt | Steps to reproduce [System.Management.Automation.CommandCompletion]::CompleteInput('', 0, @{}) Or [System.Management.Automation.CommandCompletion]::CompleteInput( {}.Ast, @(), {}.Ast.Extent.StartSc... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | SeeminglyScience |
| hostname | github.com |
| expected-hostname | github.com |
| None | b9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb |
| turbo-cache-control | no-preview |
| go-import | github.com/PowerShell/PowerShell git https://github.com/PowerShell/PowerShell.git |
| octolytics-dimension-user_id | 11524380 |
| octolytics-dimension-user_login | PowerShell |
| octolytics-dimension-repository_id | 49609581 |
| octolytics-dimension-repository_nwo | PowerShell/PowerShell |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 49609581 |
| octolytics-dimension-repository_network_root_nwo | PowerShell/PowerShell |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 6d28624802c2f7d9500239dd6870ed7031b7353b |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width