Skip to content

TerminalControl: Support MinGW path translation style (C:\ -> C:/) #18759

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

Merged
merged 1 commit into from
Apr 14, 2025

Conversation

abutcher-gh
Copy link
Contributor

Summary of the Pull Request

Support drag-n-drop path translation in the style used by MinGW programs. In particular for usage with shells like ash from busybox (https://frippery.org/busybox/).

Detailed Description of the Pull Request / Additional comments

Provides a new option "mingw" for "pathTranslationStyle".
Shown as "MinGW" with translation documented as (C:\ -> C:/) in the UI.
As per the other modes, this translates \ to / but stops there. There is no prefix/drive translation.

Validation Steps Performed

Run using busybox ash shell. Dragged directories and files from both local disks and network shares onto terminal. All were appropriately single quoted and had their backslashes replaced with forward slashes. They were directly usable by the ash shell.

Language files containing the other options have been updated to include the new one.

PR Checklist

  • Closes #xxx
  • Tests added/passed
  • Documentation updated
  • Schema updated (if necessary)

@abutcher-gh
Copy link
Contributor Author

@microsoft-github-policy-service agree

@@ -119,6 +120,11 @@ namespace winrt::Microsoft::Terminal::Control::implementation
pos += cchSingleQuoteEscape;
}

if (translationStyle == PathTranslationStyle::MinGW)
Copy link
Member

@lhecker lhecker Apr 9, 2025

Choose a reason for hiding this comment

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

This is entirely optional, but you could merge this with the following if condition if you wanted to:

if (translationStyle != PathTranslationStyle::MinGW && fullPath.size() >= 2 && fullPath.at(1) == L':')

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry for being late in getting back to this.

I thought it was clearer to early-out for the MinGW case to make it obvious that no further processing is required rather than combining the logic with the existing drive handling condition. Readers then know there will be no additional MinGW code further on in the function.

@DHowett
Copy link
Member

DHowett commented Apr 9, 2025

Thanks so much for doing this! I'll hold it for a little bit in case you take Leonard's suggestion, but we're otherwise clear to merge :)

@DHowett
Copy link
Member

DHowett commented Apr 9, 2025

/apz run

@DHowett
Copy link
Member

DHowett commented Apr 9, 2025

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@microsoft-github-policy-service microsoft-github-policy-service bot added the Needs-Tag-Fix Doesn't match tag requirements label Apr 9, 2025
@lhecker lhecker merged commit 6682bed into microsoft:main Apr 14, 2025
14 checks passed
DHowett pushed a commit to MicrosoftDocs/terminal that referenced this pull request Apr 25, 2025
Documents the new option introduced by
microsoft/terminal#18759

Co-authored-by: Adam Butcher <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs-Tag-Fix Doesn't match tag requirements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants