Title: Member tab completion fails to quote member names not directly acceptable · Issue #10198 · PowerShell/PowerShell · GitHub
Open Graph Title: Member tab completion fails to quote member names not directly acceptable · Issue #10198 · PowerShell/PowerShell
X Title: Member tab completion fails to quote member names not directly acceptable · Issue #10198 · PowerShell/PowerShell
Description: Continuing my investigation of tab completion quoting/escaping failures: Steps to reproduce $a = @{ '3hello' = 'a'} $a.
Open Graph Description: Continuing my investigation of tab completion quoting/escaping failures: Steps to reproduce $a = @{ '3hello' = 'a'} $a.
X Description: Continuing my investigation of tab completion quoting/escaping failures: Steps to reproduce $a = @{ '3hello' = 'a'} $a.<TAB> # select `3hello` property from list, then execute...
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/10198
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Member tab completion fails to quote member names not directly acceptable","articleBody":"Continuing my investigation of tab completion quoting/escaping failures:\r\n\r\n# Steps to reproduce\r\n\r\n```powershell\r\n$a = @{ '3hello' = 'a'}\r\n\r\n$a.\u003cTAB\u003e # select `3hello` property from list, then execute.\r\n```\r\n\r\n# Expected behavior\r\n\r\nthe finished completion to be:\r\n```PowerShell\r\n$a.'3hello'\r\n```\r\n\r\n# Actual behavior\r\n\r\n```none\r\n$a.3hello\r\n```\r\nWhich causes an error 'missing property name'.\r\n\r\n# Environment data\r\n\r\n\u003c!-- provide the output of $PSVersionTable --\u003e\r\n\r\n```none\r\nName Value\r\n---- -----\r\nPSVersion 6.2.2\r\nPSEdition Core\r\nGitCommitId 6.2.2\r\nOS Microsoft Windows 10.0.18941\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# Additionally\r\n\r\nTab completion after `$a.'` switches to file name completion.\r\n\r\nThe code that handles this appears to be at:\r\nhttps://github.com/PowerShell/PowerShell/blob/48c7e112db8f0506a74555c83ecb8bec509b6597/src/System.Management.Automation/engine/CommandCompletion/CompletionCompleters.cs#L6586-L6591\r\n\r\nThe field `s_charactersRequiringQuotes` is used mostly for variable name checks, but is also inadequate for that purpose (see #10006), but fails here because it doesn't handle the condition of numeric digits in the first character require quoting.\r\nhttps://github.com/PowerShell/PowerShell/blob/48c7e112db8f0506a74555c83ecb8bec509b6597/src/System.Management.Automation/engine/CommandCompletion/CompletionCompleters.cs#L4565-L4567\r\n\r\nIn PowerShell code, I would use REGEX: `^[\\p{L}_][\\w]*$`. If this regex fails on a non-empty name, the property name must be quoted. However there is probably a quicker method in C# using the `[CharExtensions]` class using `IsIdentifierStart()` (first character) and `IsIdentifierFollow()` (subsequent characters), and quote the property if the response is FALSE.\r\n","author":{"url":"https://github.com/msftrncs","@type":"Person","name":"msftrncs"},"datePublished":"2019-07-21T22:53:11.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":5},"url":"https://github.com/10198/PowerShell/issues/10198"}
| 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:8aade041-45db-8fc9-59f5-9864bc0dbbff |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DE92:262F40:23AFC3D:2FF3DEE:6A59A4CB |
| html-safe-nonce | b419bb97d047799a4cbdede1b37341d04bee9b48a84f014c3c9c795e0c1728a2 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJERTkyOjI2MkY0MDoyM0FGQzNEOjJGRjNERUU6NkE1OUE0Q0IiLCJ2aXNpdG9yX2lkIjoiOTA5MDQ0NzgzNDUyOTUwNjUwNyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 6c3f98e7eced17684a4cbae20cf1aa6b6c91731f429eac01749c85c3ca8858dd |
| hovercard-subject-tag | issue:470834243 |
| 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/10198/issue_layout |
| twitter:image | https://opengraph.githubassets.com/379b20d66aee39064470bbed2a661f570c24cab9068d9be6453879ddcc654988/PowerShell/PowerShell/issues/10198 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/379b20d66aee39064470bbed2a661f570c24cab9068d9be6453879ddcc654988/PowerShell/PowerShell/issues/10198 |
| og:image:alt | Continuing my investigation of tab completion quoting/escaping failures: Steps to reproduce $a = @{ '3hello' = 'a'} $a. |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | msftrncs |
| hostname | github.com |
| expected-hostname | github.com |
| None | a540949572872b935b393b36db38922db390ae71c859537d741b8f3eb7e545b5 |
| 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 | 0b971869dd75eec26500a9de7e85b8137c6bf0f6 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width