Skip to content

Conversation

MartinGC94
Copy link
Contributor

PR Summary

Fixes the logic for the file path completion so paths with double quote characters get single quotes added just like we do for other problematic characters in bare quote strings.

PR Context

Fixes #25629

PR Checklist

@iSazonov iSazonov added the CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log label Jun 4, 2025
_ = sb.Append('\'');
quotesAreNeeded = true;
// Bareword or singlequoted input string.
if (path[index].IsSingleQuote())
Copy link
Collaborator

Choose a reason for hiding this comment

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

It seems the method would be more readable if we ridded of useSingleQuoteEscapeRules and replace it with stringType is StringConstantType.SingleQuoted or StringConstantType.BareWord.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That check will change when my PR to keep variables when tab completing paths is merged. If someone is tab completing a bareword string with a variable it needs to use double quote rules.

$null = New-Item -Path $TestFile1 -Force
$Expected = "'$($TestFile1.Insert($TestFile1.LastIndexOf($BadQuote), "'"))'"

$res = TabExpansion2 -inputScript "Get-ChildItem -Path '$TestDrive\"
Copy link
Collaborator

Choose a reason for hiding this comment

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

If it is intentional to have single quote it is not obvious so please add a comment.

@iSazonov iSazonov self-assigned this Jun 9, 2025
@iSazonov
Copy link
Collaborator

iSazonov commented Jun 9, 2025

/azp run PowerShell-Windows-Packaging-CI,PowerShell-CI-linux-packaging

Copy link

Azure Pipelines could not run because the pipeline triggers exclude this branch/path.

@iSazonov iSazonov merged commit 0380034 into PowerShell:master Jun 9, 2025
36 checks passed
Copy link
Contributor

microsoft-github-policy-service bot commented Jun 9, 2025

📣 Hey @@MartinGC94, how did we do? We would love to hear your feedback with the link below! 🗣️

🔗 https://aka.ms/PSRepoFeedback

@MartinGC94 MartinGC94 deleted the fixfilequote branch June 9, 2025 06:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tab completion does not quote Unicode filenames with full-width characters, leading to incorrect command parsing

2 participants