-
Notifications
You must be signed in to change notification settings - Fork 8.5k
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
Add a new (advanced) profile setting, pathTranslationStyle #18195
Conversation
Thoughts:
Notes for later: I need to add |
This comment has been minimized.
This comment has been minimized.
This does not preclude us shipping custom mapping support in the future. It would make it more annoying (we could set |
This comment has been minimized.
This comment has been minimized.
I like And absolutely: I will use this in the Git Bash profile that is installed by Git for Windows' installer (opt-in). Great work @DHowett! |
fc90723
to
9135943
Compare
This comment has been minimized.
This comment has been minimized.
`pathTranslationStyle` has four options: - `none`: Do no translation - `wsl`: Translate `C:\` to `/mnt/c` and `\\wsl$\Foo\bar` to `/bar` - `cygwin`: Translate `C:\` to `/cygdrive/c` - `msys2`: Translate `C:\` to `/c` It is intended as a broadly-supported replacement for us checking the source every time the user drops a path.
9135943
to
a596124
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
neat
<value>WSL (C:\ -> /mnt/c)</value> | ||
<comment>{Locked="WSL","C:\","/mnt/c"} An option to choose from for the "path translation" setting.</comment> | ||
</data> | ||
<data name="Profile_PathTranslationStyleCygwin.Content" xml:space="preserve"> | ||
<value>Cygwin (C:\ -> /cygdrive/c)</value> | ||
<comment>{Locked="Cygwin","C:\","/cygdrive/c"} An option to choose from for the "path translation" setting.</comment> | ||
</data> | ||
<data name="Profile_PathTranslationStyleMsys2.Content" xml:space="preserve"> | ||
<value>MSYS2 (C:\ -> /c)</value> | ||
<comment>{Locked="MSYS2","C:\","/c"} An option to choose from for the "path translation" setting.</comment> | ||
</data> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love the examples!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh i didn't understand this until now. thanks, i should do this
{ | ||
// Stripping the UNC name and distribution prefix only applies to WSL. | ||
static constexpr std::wstring_view wslPathPrefixes[] = { L"//wsl.localhost/", L"//wsl$/" }; | ||
for (auto prefix : wslPathPrefixes) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for (auto prefix : wslPathPrefixes) | |
for (const auto prefix : wslPathPrefixes) |
Oh! Don't forget the schema! |
…l-ptm # Conflicts: # src/cascadia/TerminalSettingsEditor/Resources/en-US/Resources.resw
b59067b
to
5960ef3
Compare
In #18195, we introduced a real `pathTranslationStyle` setting. I'm not backporting that whole thing.
In #18195, we introduced a real `pathTranslationStyle` setting. I'm not backporting that whole thing.
When file/folder is dropped to the terminal, its path is translated and quoted with a pair of single quotes if necessary. However, the terminal control does not escape single quotes (allowed in the Win32 subsystem) that need escapes when translated. On the translation styles other than `"none"` (note: all other translation styles are currently intended for the POSIX shell), it causes incorrect path to be pasted when the path contains one or more single quotes (see #18006 for an example). With this commit, the terminal control escapes a single quote with a valid escape sequence `'\''` (finish quote, print a single quote then begin quote again) when the path translation is required. ## History ### v1 → v2 * Changed escape sequence from `'"'"'` to much shorter `'\''`. * Reflected comments by the reviewer. ### v2 → v3 * Overhaul after addition of multiple path translation styles (not just WSL but Cygwin and MSYS). * More clarification both in the code and in the commit message. ### v3 → v4 (current) * Minor clarification both in the code and in the commit message. ## References and Relevant Issues * #18006 * #16214 * #18195 ## Detailed Description of the Pull Request / Additional comments This is a follow-up of #16214 and #18195, fixing #18006. Closes #18006
When file/folder is dropped to the terminal, its path is translated and quoted with a pair of single quotes if necessary. However, the terminal control does not escape single quotes (allowed in the Win32 subsystem) that need escapes when translated. On the translation styles other than `"none"` (note: all other translation styles are currently intended for the POSIX shell), it causes incorrect path to be pasted when the path contains one or more single quotes (see #18006 for an example). With this commit, the terminal control escapes a single quote with a valid escape sequence `'\''` (finish quote, print a single quote then begin quote again) when the path translation is required. * Changed escape sequence from `'"'"'` to much shorter `'\''`. * Reflected comments by the reviewer. * Overhaul after addition of multiple path translation styles (not just WSL but Cygwin and MSYS). * More clarification both in the code and in the commit message. * Minor clarification both in the code and in the commit message. * #18006 * #16214 * #18195 This is a follow-up of #16214 and #18195, fixing #18006. Closes #18006 (cherry picked from commit ae90d52) Service-Card-Id: PVTI_lADOAF3p4s4AmhmszgVEvdY Service-Version: 1.21
When file/folder is dropped to the terminal, its path is translated and quoted with a pair of single quotes if necessary. However, the terminal control does not escape single quotes (allowed in the Win32 subsystem) that need escapes when translated. On the translation styles other than `"none"` (note: all other translation styles are currently intended for the POSIX shell), it causes incorrect path to be pasted when the path contains one or more single quotes (see #18006 for an example). With this commit, the terminal control escapes a single quote with a valid escape sequence `'\''` (finish quote, print a single quote then begin quote again) when the path translation is required. * Changed escape sequence from `'"'"'` to much shorter `'\''`. * Reflected comments by the reviewer. * Overhaul after addition of multiple path translation styles (not just WSL but Cygwin and MSYS). * More clarification both in the code and in the commit message. * Minor clarification both in the code and in the commit message. * #18006 * #16214 * #18195 This is a follow-up of #16214 and #18195, fixing #18006. Closes #18006 (cherry picked from commit ae90d52) Service-Card-Id: PVTI_lADOAF3p4s4AmhmQzgVEvdU Service-Version: 1.22
`pathTranslationStyle` has four options: - `none`: Do no translation - `wsl`: Translate `C:\` to `/mnt/c` and `\\wsl$\Foo\bar` to `/bar` - `cygwin`: Translate `C:\` to `/cygdrive/c` - `msys2`: Translate `C:\` to `/c` It is intended as a broadly-supported replacement for us checking the source every time the user drops a path. We no longer need to push the source name all the way down to the control. I am hesitant to commit to using other folks' product names in our settings model, however, these are almost certainly more recognizable than whatever other weird names we could come up with. The Git Bash fragment extension profile could conceivably use `pathTranslationStyle` `msys2` to make sure drag/dropped paths look right. (cherry picked from commit 0689067) Service-Card-Id: PVTI_lADOAF3p4s4AmhmQzgW9l6A Service-Version: 1.22
When file/folder is dropped to the terminal, its path is translated and quoted with a pair of single quotes if necessary. However, the terminal control does not escape single quotes (allowed in the Win32 subsystem) that need escapes when translated. On the translation styles other than `"none"` (note: all other translation styles are currently intended for the POSIX shell), it causes incorrect path to be pasted when the path contains one or more single quotes (see #18006 for an example). With this commit, the terminal control escapes a single quote with a valid escape sequence `'\''` (finish quote, print a single quote then begin quote again) when the path translation is required. * Changed escape sequence from `'"'"'` to much shorter `'\''`. * Reflected comments by the reviewer. * Overhaul after addition of multiple path translation styles (not just WSL but Cygwin and MSYS). * More clarification both in the code and in the commit message. * Minor clarification both in the code and in the commit message. * #18006 * #16214 * #18195 This is a follow-up of #16214 and #18195, fixing #18006. Closes #18006 Supersedes 7878728 (cherry picked from commit ae90d52) Service-Card-Id: PVTI_lADOAF3p4s4AmhmQzgVEvdU Service-Version: 1.22
`pathTranslationStyle` has four options: - `none`: Do no translation - `wsl`: Translate `C:\` to `/mnt/c` and `\\wsl$\Foo\bar` to `/bar` - `cygwin`: Translate `C:\` to `/cygdrive/c` - `msys2`: Translate `C:\` to `/c` It is intended as a broadly-supported replacement for us checking the source every time the user drops a path. We no longer need to push the source name all the way down to the control. I am hesitant to commit to using other folks' product names in our settings model, however, these are almost certainly more recognizable than whatever other weird names we could come up with. The Git Bash fragment extension profile could conceivably use `pathTranslationStyle` `msys2` to make sure drag/dropped paths look right. (cherry picked from commit 0689067) Service-Card-Id: PVTI_lADOAF3p4s4AmhmQzgW9l6A Service-Version: 1.22
When file/folder is dropped to the terminal, its path is translated and quoted with a pair of single quotes if necessary. However, the terminal control does not escape single quotes (allowed in the Win32 subsystem) that need escapes when translated. On the translation styles other than `"none"` (note: all other translation styles are currently intended for the POSIX shell), it causes incorrect path to be pasted when the path contains one or more single quotes (see #18006 for an example). With this commit, the terminal control escapes a single quote with a valid escape sequence `'\''` (finish quote, print a single quote then begin quote again) when the path translation is required. * Changed escape sequence from `'"'"'` to much shorter `'\''`. * Reflected comments by the reviewer. * Overhaul after addition of multiple path translation styles (not just WSL but Cygwin and MSYS). * More clarification both in the code and in the commit message. * Minor clarification both in the code and in the commit message. * #18006 * #16214 * #18195 This is a follow-up of #16214 and #18195, fixing #18006. Closes #18006 Supersedes 7878728 (cherry picked from commit ae90d52) Service-Card-Id: PVTI_lADOAF3p4s4AmhmQzgVEvdU Service-Version: 1.22
FYI, on Cygwin (and MSYS2) the cygdrive prefix can be changed in |
pathTranslationStyle
has four options:none
: Do no translationwsl
: TranslateC:\
to/mnt/c
and\\wsl$\Foo\bar
to/bar
cygwin
: TranslateC:\
to/cygdrive/c
msys2
: TranslateC:\
to/c
It is intended as a broadly-supported replacement for us checking the
source every time the user drops a path.
We no longer need to push the source name all the way down to the control.
I am hesitant to commit to using other folks' product names in our settings model,
however, these are almost certainly more recognizable than whatever other weird
names we could come up with.
The Git Bash fragment extension profile could conceivably use
pathTranslationStyle
msys2
to make sure drag/dropped paths look right.