From 9a262e947c8eaa504ddfdfc03ec10eff38f55981 Mon Sep 17 00:00:00 2001 From: "Dustin L. Howett" Date: Fri, 15 Nov 2024 17:55:34 -0600 Subject: [PATCH] Add a new (advanced) profile setting, pathTranslationStyle (#18195) `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 068906714fa190e89020a3f59809ed9237b94708) Service-Card-Id: PVTI_lADOAF3p4s4AmhmQzgW9l6A Service-Version: 1.22 --- .github/actions/spelling/expect/expect.txt | 1 + doc/cascadia/profiles.schema.json | 11 ++ .../TerminalControl/ControlInteractivity.cpp | 13 -- .../TerminalControl/ControlInteractivity.h | 1 - .../TerminalControl/ControlInteractivity.idl | 2 - .../TerminalControl/IControlSettings.idl | 11 +- src/cascadia/TerminalControl/TermControl.cpp | 120 ++++++++---------- .../ProfileViewModel.cpp | 5 + .../TerminalSettingsEditor/ProfileViewModel.h | 2 + .../ProfileViewModel.idl | 4 + .../Profiles_Advanced.xaml | 12 ++ .../Resources/en-US/Resources.resw | 40 ++++++ .../TerminalSettingsModel/EnumMappings.cpp | 1 + .../TerminalSettingsModel/EnumMappings.h | 1 + .../TerminalSettingsModel/EnumMappings.idl | 1 + .../TerminalSettingsModel/MTSMSettings.h | 3 +- .../TerminalSettingsModel/Profile.idl | 2 + .../TerminalSettings.cpp | 2 +- .../TerminalSettingsModel/TerminalSettings.h | 3 +- .../TerminalSettingsSerializationHelpers.h | 10 ++ .../WslDistroGenerator.cpp | 1 + src/cascadia/inc/ControlProperties.h | 4 +- 22 files changed, 162 insertions(+), 88 deletions(-) diff --git a/.github/actions/spelling/expect/expect.txt b/.github/actions/spelling/expect/expect.txt index f46a0e88d0..9f46575410 100644 --- a/.github/actions/spelling/expect/expect.txt +++ b/.github/actions/spelling/expect/expect.txt @@ -341,6 +341,7 @@ CXVIRTUALSCREEN CXVSCROLL CYFRAME CYFULLSCREEN +cygdrive CYHSCROLL CYMIN CYPADDEDBORDER diff --git a/doc/cascadia/profiles.schema.json b/doc/cascadia/profiles.schema.json index 0b3698729e..4bf6067f0a 100644 --- a/doc/cascadia/profiles.schema.json +++ b/doc/cascadia/profiles.schema.json @@ -3104,6 +3104,17 @@ "default": false, "description": "When set to true, the window will have an acrylic material background. When set to false, the window will have a plain, untextured background.", "type": "boolean" + }, + "pathTranslationStyle": { + "default": "none", + "description": "Controls how file paths are transformed when they are dragged and dropped on the terminal. Possible values are \"none\", \"wsl\", \"cygwin\" and \"msys2\".", + "enum": [ + "none", + "wsl", + "cygwin", + "msys2" + ], + "type": "string" } } }, diff --git a/src/cascadia/TerminalControl/ControlInteractivity.cpp b/src/cascadia/TerminalControl/ControlInteractivity.cpp index 64ddfdc3f3..21a373bc89 100644 --- a/src/cascadia/TerminalControl/ControlInteractivity.cpp +++ b/src/cascadia/TerminalControl/ControlInteractivity.cpp @@ -725,17 +725,4 @@ namespace winrt::Microsoft::Terminal::Control::implementation { return _core->GetRenderData(); } - - // Method Description: - // - Used by the TermControl to know if it should translate drag-dropped - // paths into WSL-friendly paths. - // Arguments: - // - - // Return Value: - // - true if the connection we were created with was a WSL profile. - bool ControlInteractivity::ManglePathsForWsl() - { - const auto source{ _core->Settings().ProfileSource() }; - return til::equals_insensitive_ascii(source, L"Windows.Terminal.Wsl") || til::equals_insensitive_ascii(source, L"Microsoft.WSL"); - } } diff --git a/src/cascadia/TerminalControl/ControlInteractivity.h b/src/cascadia/TerminalControl/ControlInteractivity.h index 22eaa95c39..78268af95a 100644 --- a/src/cascadia/TerminalControl/ControlInteractivity.h +++ b/src/cascadia/TerminalControl/ControlInteractivity.h @@ -86,7 +86,6 @@ namespace winrt::Microsoft::Terminal::Control::implementation const Windows::Foundation::IReference& formats); void RequestPasteTextFromClipboard(); void SetEndSelectionPoint(const Core::Point pixelPosition); - bool ManglePathsForWsl(); uint64_t Id(); void AttachToNewControl(const Microsoft::Terminal::Control::IKeyBindings& keyBindings); diff --git a/src/cascadia/TerminalControl/ControlInteractivity.idl b/src/cascadia/TerminalControl/ControlInteractivity.idl index 926c1e3b0a..1a7b5907ed 100644 --- a/src/cascadia/TerminalControl/ControlInteractivity.idl +++ b/src/cascadia/TerminalControl/ControlInteractivity.idl @@ -66,8 +66,6 @@ namespace Microsoft.Terminal.Control void UpdateScrollbar(Single newValue); - Boolean ManglePathsForWsl { get; }; - event Windows.Foundation.TypedEventHandler OpenHyperlink; event Windows.Foundation.TypedEventHandler ScrollPositionChanged; event Windows.Foundation.TypedEventHandler PasteFromClipboard; diff --git a/src/cascadia/TerminalControl/IControlSettings.idl b/src/cascadia/TerminalControl/IControlSettings.idl index 96b5b6b95f..ccd4445c48 100644 --- a/src/cascadia/TerminalControl/IControlSettings.idl +++ b/src/cascadia/TerminalControl/IControlSettings.idl @@ -21,6 +21,14 @@ namespace Microsoft.Terminal.Control Aliased }; + enum PathTranslationStyle + { + None = 0, + WSL, + Cygwin, + MSYS2 + }; + // Class Description: // TerminalSettings encapsulates all settings that control the // TermControl's behavior. In these settings there is both the entirety @@ -30,7 +38,6 @@ namespace Microsoft.Terminal.Control Microsoft.Terminal.Control.IControlAppearance { String ProfileName; - String ProfileSource; Boolean EnableUnfocusedAcrylic { get; }; Guid SessionId { get; }; @@ -69,6 +76,8 @@ namespace Microsoft.Terminal.Control Boolean RightClickContextMenu { get; }; Boolean RepositionCursorWithMouse { get; }; + PathTranslationStyle PathTranslationStyle { get; }; + // NOTE! When adding something here, make sure to update ControlProperties.h too! }; } diff --git a/src/cascadia/TerminalControl/TermControl.cpp b/src/cascadia/TerminalControl/TermControl.cpp index 6f96cefc94..bb84a9ffb6 100644 --- a/src/cascadia/TerminalControl/TermControl.cpp +++ b/src/cascadia/TerminalControl/TermControl.cpp @@ -58,6 +58,54 @@ static Microsoft::Console::TSF::Handle& GetTSFHandle() namespace winrt::Microsoft::Terminal::Control::implementation { + static void _translatePathInPlace(std::wstring& fullPath, PathTranslationStyle translationStyle) + { + static constexpr wil::zwstring_view s_pathPrefixes[] = { + {}, + /* WSL */ L"/mnt/", + /* Cygwin */ L"/cygdrive/", + /* MSYS2 */ L"/", + }; + + if (translationStyle == PathTranslationStyle::None) + { + return; + } + + // All of the other path translation modes current result in /-delimited paths + std::replace(fullPath.begin(), fullPath.end(), L'\\', L'/'); + + if (fullPath.size() >= 2 && fullPath.at(1) == L':') + { + // C:/foo/bar -> Cc/foo/bar + fullPath.at(1) = til::tolower_ascii(fullPath.at(0)); + // Cc/foo/bar -> [PREFIX]c/foo/bar + fullPath.replace(0, 1, s_pathPrefixes[static_cast(translationStyle)]); + } + else if (translationStyle == PathTranslationStyle::WSL) + { + // 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) + { + if (til::starts_with(fullPath, prefix)) + { + if (const auto idx = fullPath.find(L'/', prefix.size()); idx != std::wstring::npos) + { + // //wsl.localhost/Ubuntu-18.04/foo/bar -> /foo/bar + fullPath.erase(0, idx); + } + else + { + // //wsl.localhost/Ubuntu-18.04 -> / + fullPath = L"/"; + } + break; + } + } + } + } + TsfDataProvider::TsfDataProvider(TermControl* termControl) noexcept : _termControl{ termControl } { @@ -3196,79 +3244,19 @@ namespace winrt::Microsoft::Terminal::Control::implementation allPathsString += L" "; } - // Fix path for WSL - // In the fullness of time, we should likely plumb this up - // to the TerminalApp layer, and have it make the decision - // if this control should have its path mangled (and do the - // mangling), rather than exposing the source concept to the - // Control layer. - // - // However, it's likely that the control layer may need to - // know about the source anyways in the future, to support - // GH#3158 - const auto isWSL = _interactivity.ManglePathsForWsl(); + const auto translationStyle{ _core.Settings().PathTranslationStyle() }; + _translatePathInPlace(fullPath, translationStyle); - if (isWSL) - { - std::replace(fullPath.begin(), fullPath.end(), L'\\', L'/'); - - if (fullPath.size() >= 2 && fullPath.at(1) == L':') - { - // C:/foo/bar -> Cc/foo/bar - fullPath.at(1) = til::tolower_ascii(fullPath.at(0)); - // Cc/foo/bar -> /mnt/c/foo/bar - fullPath.replace(0, 1, L"/mnt/"); - } - else - { - static constexpr std::wstring_view wslPathPrefixes[] = { L"//wsl.localhost/", L"//wsl$/" }; - for (auto prefix : wslPathPrefixes) - { - if (til::starts_with(fullPath, prefix)) - { - if (const auto idx = fullPath.find(L'/', prefix.size()); idx != std::wstring::npos) - { - // //wsl.localhost/Ubuntu-18.04/foo/bar -> /foo/bar - fullPath.erase(0, idx); - } - else - { - // //wsl.localhost/Ubuntu-18.04 -> / - fullPath = L"/"; - } - break; - } - } - } - } - - const auto quotesNeeded = isWSL || fullPath.find(L' ') != std::wstring::npos; - const auto quotesChar = isWSL ? L'\'' : L'"'; + // All translated paths get quotes, and all strings spaces get quotes; all translated paths get single quotes + const auto quotesNeeded = translationStyle != PathTranslationStyle::None || fullPath.find(L' ') != std::wstring::npos; + const auto quotesChar = translationStyle != PathTranslationStyle::None ? L'\'' : L'"'; // Append fullPath and also wrap it in quotes if needed if (quotesNeeded) { allPathsString.push_back(quotesChar); } - if (isWSL) - { - // Fix quoted path for WSL - // Single quote is allowed on the Win32 subsystem and must be processed on WSL profiles. - // Note that we assume that all paths are quoted using a pair of single quotes for WSL. - std::wstring_view fullPathView{ fullPath }; - size_t pos; - while ((pos = fullPathView.find(L'\'')) != std::wstring_view::npos) - { - allPathsString.append(fullPathView.begin(), fullPathView.begin() + pos); - allPathsString.append(L"'\\''"); - fullPathView.remove_prefix(pos + 1); - } - allPathsString.append(fullPathView); - } - else - { - allPathsString.append(fullPath); - } + allPathsString.append(fullPath); if (quotesNeeded) { allPathsString.push_back(quotesChar); diff --git a/src/cascadia/TerminalSettingsEditor/ProfileViewModel.cpp b/src/cascadia/TerminalSettingsEditor/ProfileViewModel.cpp index 66d8371c3e..b63befd83b 100644 --- a/src/cascadia/TerminalSettingsEditor/ProfileViewModel.cpp +++ b/src/cascadia/TerminalSettingsEditor/ProfileViewModel.cpp @@ -39,6 +39,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation INITIALIZE_BINDABLE_ENUM_SETTING(AntiAliasingMode, TextAntialiasingMode, winrt::Microsoft::Terminal::Control::TextAntialiasingMode, L"Profile_AntialiasingMode", L"Content"); INITIALIZE_BINDABLE_ENUM_SETTING_REVERSE_ORDER(CloseOnExitMode, CloseOnExitMode, winrt::Microsoft::Terminal::Settings::Model::CloseOnExitMode, L"Profile_CloseOnExit", L"Content"); INITIALIZE_BINDABLE_ENUM_SETTING(ScrollState, ScrollbarState, winrt::Microsoft::Terminal::Control::ScrollbarState, L"Profile_ScrollbarVisibility", L"Content"); + INITIALIZE_BINDABLE_ENUM_SETTING(PathTranslationStyle, PathTranslationStyle, winrt::Microsoft::Terminal::Control::PathTranslationStyle, L"Profile_PathTranslationStyle", L"Content"); // Add a property changed handler to our own property changed event. // This propagates changes from the settings model to anybody listening to our @@ -76,6 +77,10 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation { _NotifyChanges(L"HideIcon"); } + else if (viewModelProperty == L"PathTranslationStyle") + { + _NotifyChanges(L"CurrentPathTranslationStyle"); + } }); // Do the same for the starting directory diff --git a/src/cascadia/TerminalSettingsEditor/ProfileViewModel.h b/src/cascadia/TerminalSettingsEditor/ProfileViewModel.h index 250ef052dc..3bb865e85e 100644 --- a/src/cascadia/TerminalSettingsEditor/ProfileViewModel.h +++ b/src/cascadia/TerminalSettingsEditor/ProfileViewModel.h @@ -124,12 +124,14 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation OBSERVABLE_PROJECTED_SETTING(_profile, AllowVtChecksumReport); OBSERVABLE_PROJECTED_SETTING(_profile, AllowVtClipboardWrite); OBSERVABLE_PROJECTED_SETTING(_profile, AnswerbackMessage); + OBSERVABLE_PROJECTED_SETTING(_profile, PathTranslationStyle); WINRT_PROPERTY(bool, IsBaseLayer, false); WINRT_PROPERTY(bool, FocusDeleteButton, false); GETSET_BINDABLE_ENUM_SETTING(AntiAliasingMode, Microsoft::Terminal::Control::TextAntialiasingMode, AntialiasingMode); GETSET_BINDABLE_ENUM_SETTING(CloseOnExitMode, Microsoft::Terminal::Settings::Model::CloseOnExitMode, CloseOnExit); GETSET_BINDABLE_ENUM_SETTING(ScrollState, Microsoft::Terminal::Control::ScrollbarState, ScrollState); + GETSET_BINDABLE_ENUM_SETTING(PathTranslationStyle, Microsoft::Terminal::Control::PathTranslationStyle, PathTranslationStyle); private: Model::Profile _profile; diff --git a/src/cascadia/TerminalSettingsEditor/ProfileViewModel.idl b/src/cascadia/TerminalSettingsEditor/ProfileViewModel.idl index c4c9996773..c8a07374d7 100644 --- a/src/cascadia/TerminalSettingsEditor/ProfileViewModel.idl +++ b/src/cascadia/TerminalSettingsEditor/ProfileViewModel.idl @@ -58,6 +58,9 @@ namespace Microsoft.Terminal.Settings.Editor IInspectable CurrentScrollState; Windows.Foundation.Collections.IObservableVector ScrollStateList { get; }; + IInspectable CurrentPathTranslationStyle; + Windows.Foundation.Collections.IObservableVector PathTranslationStyleList { get; }; + Boolean CanDeleteProfile { get; }; Boolean FocusDeleteButton; Boolean IsBaseLayer; @@ -116,5 +119,6 @@ namespace Microsoft.Terminal.Settings.Editor OBSERVABLE_PROJECTED_PROFILE_SETTING(Boolean, AllowVtChecksumReport); OBSERVABLE_PROJECTED_PROFILE_SETTING(String, AnswerbackMessage); OBSERVABLE_PROJECTED_PROFILE_SETTING(Boolean, AllowVtClipboardWrite); + OBSERVABLE_PROJECTED_PROFILE_SETTING(Microsoft.Terminal.Control.PathTranslationStyle, PathTranslationStyle); } } diff --git a/src/cascadia/TerminalSettingsEditor/Profiles_Advanced.xaml b/src/cascadia/TerminalSettingsEditor/Profiles_Advanced.xaml index 347f909d06..a9e0a23d81 100644 --- a/src/cascadia/TerminalSettingsEditor/Profiles_Advanced.xaml +++ b/src/cascadia/TerminalSettingsEditor/Profiles_Advanced.xaml @@ -156,6 +156,18 @@ Style="{StaticResource ToggleSwitchInExpanderStyle}" /> + + + + + diff --git a/src/cascadia/TerminalSettingsEditor/Resources/en-US/Resources.resw b/src/cascadia/TerminalSettingsEditor/Resources/en-US/Resources.resw index e785f4d1d6..8f40988a04 100644 --- a/src/cascadia/TerminalSettingsEditor/Resources/en-US/Resources.resw +++ b/src/cascadia/TerminalSettingsEditor/Resources/en-US/Resources.resw @@ -1900,4 +1900,44 @@ Useful for troubleshooting or developing Terminal. Additional description for what the "debug features enabled" setting does. Presented near "Globals_DebugFeaturesEnabled.Header". + + Path translation + Name for a control to select how file and directory paths are translated. + + + Path translation + Name for a control to select how file and directory paths are translated. + + + Controls how file and directory paths are translated during drag-and-drop operations. + A description for what the "path translation" setting does. Presented near "Profile_PathTranslationStyle.Header". + + + None + An option to choose from for the "path translation" setting. + + + WSL (C:\ -> /mnt/c) + {Locked="WSL","C:\","/mnt/c"} An option to choose from for the "path translation" setting. + + + Cygwin (C:\ -> /cygdrive/c) + {Locked="Cygwin","C:\","/cygdrive/c"} An option to choose from for the "path translation" setting. + + + MSYS2 (C:\ -> /c) + {Locked="MSYS2","C:\","/c"} An option to choose from for the "path translation" setting. + + + Profile no longer detected + + + This automatically-detected profile appears to have been uninstalled. Changes you have made to it are preserved, but it cannot be used until it has been reinstalled. + + + Original Source + + + Indicates the software that originally created this profile. + diff --git a/src/cascadia/TerminalSettingsModel/EnumMappings.cpp b/src/cascadia/TerminalSettingsModel/EnumMappings.cpp index 2ab4afc15c..7895bec7d9 100644 --- a/src/cascadia/TerminalSettingsModel/EnumMappings.cpp +++ b/src/cascadia/TerminalSettingsModel/EnumMappings.cpp @@ -51,6 +51,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation DEFINE_ENUM_MAP(Microsoft::Terminal::Core::CursorStyle, CursorStyle); DEFINE_ENUM_MAP(Microsoft::Terminal::Settings::Model::IntenseStyle, IntenseTextStyle); DEFINE_ENUM_MAP(Microsoft::Terminal::Core::AdjustTextMode, AdjustIndistinguishableColors); + DEFINE_ENUM_MAP(Microsoft::Terminal::Control::PathTranslationStyle, PathTranslationStyle); // FontWeight is special because the JsonUtils::ConversionTrait for it // creates a FontWeight object, but we need to use the uint16_t value. diff --git a/src/cascadia/TerminalSettingsModel/EnumMappings.h b/src/cascadia/TerminalSettingsModel/EnumMappings.h index 57f5681de8..15fbf50a40 100644 --- a/src/cascadia/TerminalSettingsModel/EnumMappings.h +++ b/src/cascadia/TerminalSettingsModel/EnumMappings.h @@ -48,6 +48,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation static winrt::Windows::Foundation::Collections::IMap FontWeight(); static winrt::Windows::Foundation::Collections::IMap IntenseTextStyle(); static winrt::Windows::Foundation::Collections::IMap AdjustIndistinguishableColors(); + static winrt::Windows::Foundation::Collections::IMap PathTranslationStyle(); }; } diff --git a/src/cascadia/TerminalSettingsModel/EnumMappings.idl b/src/cascadia/TerminalSettingsModel/EnumMappings.idl index 8b4fc9493a..57735eccd5 100644 --- a/src/cascadia/TerminalSettingsModel/EnumMappings.idl +++ b/src/cascadia/TerminalSettingsModel/EnumMappings.idl @@ -30,5 +30,6 @@ namespace Microsoft.Terminal.Settings.Model static Windows.Foundation.Collections.IMap AdjustIndistinguishableColors { get; }; static Windows.Foundation.Collections.IMap FontWeight { get; }; static Windows.Foundation.Collections.IMap IntenseTextStyle { get; }; + static Windows.Foundation.Collections.IMap PathTranslationStyle { get; }; } } diff --git a/src/cascadia/TerminalSettingsModel/MTSMSettings.h b/src/cascadia/TerminalSettingsModel/MTSMSettings.h index a668428ad9..0eb418b6f8 100644 --- a/src/cascadia/TerminalSettingsModel/MTSMSettings.h +++ b/src/cascadia/TerminalSettingsModel/MTSMSettings.h @@ -103,7 +103,8 @@ Author(s): X(bool, ForceVTInput, "compatibility.input.forceVT", false) \ X(bool, AllowVtChecksumReport, "compatibility.allowDECRQCRA", false) \ X(bool, AllowVtClipboardWrite, "compatibility.allowOSC52", true) \ - X(bool, AllowKeypadMode, "compatibility.allowDECNKM", false) + X(bool, AllowKeypadMode, "compatibility.allowDECNKM", false) \ + X(Microsoft::Terminal::Control::PathTranslationStyle, PathTranslationStyle, "pathTranslationStyle", Microsoft::Terminal::Control::PathTranslationStyle::None) // Intentionally omitted Profile settings: // * Name diff --git a/src/cascadia/TerminalSettingsModel/Profile.idl b/src/cascadia/TerminalSettingsModel/Profile.idl index 4b8ff06085..0d1ffe9f36 100644 --- a/src/cascadia/TerminalSettingsModel/Profile.idl +++ b/src/cascadia/TerminalSettingsModel/Profile.idl @@ -95,5 +95,7 @@ namespace Microsoft.Terminal.Settings.Model INHERITABLE_PROFILE_SETTING(Boolean, AllowVtChecksumReport); INHERITABLE_PROFILE_SETTING(Boolean, AllowKeypadMode); INHERITABLE_PROFILE_SETTING(Boolean, AllowVtClipboardWrite); + + INHERITABLE_PROFILE_SETTING(Microsoft.Terminal.Control.PathTranslationStyle, PathTranslationStyle); } } diff --git a/src/cascadia/TerminalSettingsModel/TerminalSettings.cpp b/src/cascadia/TerminalSettingsModel/TerminalSettings.cpp index b18e9cd222..ff9860aef6 100644 --- a/src/cascadia/TerminalSettingsModel/TerminalSettings.cpp +++ b/src/cascadia/TerminalSettingsModel/TerminalSettings.cpp @@ -288,7 +288,6 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation // Fill in the remaining properties from the profile _ProfileName = profile.Name(); - _ProfileSource = profile.Source(); const auto fontInfo = profile.FontInfo(); _FontFace = fontInfo.FontFace(); @@ -350,6 +349,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation _ForceVTInput = profile.ForceVTInput(); _AllowVtChecksumReport = profile.AllowVtChecksumReport(); _AllowVtClipboardWrite = profile.AllowVtClipboardWrite(); + _PathTranslationStyle = profile.PathTranslationStyle(); } // Method Description: diff --git a/src/cascadia/TerminalSettingsModel/TerminalSettings.h b/src/cascadia/TerminalSettingsModel/TerminalSettings.h index 48c92fdd75..9591ad3487 100644 --- a/src/cascadia/TerminalSettingsModel/TerminalSettings.h +++ b/src/cascadia/TerminalSettingsModel/TerminalSettings.h @@ -120,7 +120,6 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation // ------------------------ End of Core Settings ----------------------- INHERITABLE_SETTING(Model::TerminalSettings, hstring, ProfileName); - INHERITABLE_SETTING(Model::TerminalSettings, hstring, ProfileSource); INHERITABLE_SETTING(Model::TerminalSettings, guid, SessionId); INHERITABLE_SETTING(Model::TerminalSettings, bool, EnableUnfocusedAcrylic, false); @@ -179,6 +178,8 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation INHERITABLE_SETTING(Model::TerminalSettings, bool, ReloadEnvironmentVariables, true); + INHERITABLE_SETTING(Model::TerminalSettings, Microsoft::Terminal::Control::PathTranslationStyle, PathTranslationStyle, Microsoft::Terminal::Control::PathTranslationStyle::None); + private: std::optional> _ColorTable; std::span _getColorTableImpl(); diff --git a/src/cascadia/TerminalSettingsModel/TerminalSettingsSerializationHelpers.h b/src/cascadia/TerminalSettingsModel/TerminalSettingsSerializationHelpers.h index 4d2a84a5e6..474bbc3432 100644 --- a/src/cascadia/TerminalSettingsModel/TerminalSettingsSerializationHelpers.h +++ b/src/cascadia/TerminalSettingsModel/TerminalSettingsSerializationHelpers.h @@ -790,3 +790,13 @@ JSON_ENUM_MAPPER(::winrt::Microsoft::Terminal::Control::DefaultInputScope) pair_type{ "alphanumericHalfWidth", ValueType::AlphanumericHalfWidth }, }; }; + +JSON_ENUM_MAPPER(::winrt::Microsoft::Terminal::Control::PathTranslationStyle) +{ + static constexpr std::array mappings = { + pair_type{ "none", ValueType::None }, + pair_type{ "wsl", ValueType::WSL }, + pair_type{ "cygwin", ValueType::Cygwin }, + pair_type{ "msys2", ValueType::MSYS2 }, + }; +}; diff --git a/src/cascadia/TerminalSettingsModel/WslDistroGenerator.cpp b/src/cascadia/TerminalSettingsModel/WslDistroGenerator.cpp index 50285fd824..cb1d220a90 100644 --- a/src/cascadia/TerminalSettingsModel/WslDistroGenerator.cpp +++ b/src/cascadia/TerminalSettingsModel/WslDistroGenerator.cpp @@ -66,6 +66,7 @@ static winrt::com_ptr makeProfile(const std::wstring& d WSLDistro->StartingDirectory(winrt::hstring{ DEFAULT_STARTING_DIRECTORY }); } WSLDistro->Icon(L"ms-appx:///ProfileIcons/{9acb9455-ca41-5af7-950f-6bca1bc9722f}.png"); + WSLDistro->PathTranslationStyle(winrt::Microsoft::Terminal::Control::PathTranslationStyle::WSL); return WSLDistro; } diff --git a/src/cascadia/inc/ControlProperties.h b/src/cascadia/inc/ControlProperties.h index bd7439822b..42c3b1b9d3 100644 --- a/src/cascadia/inc/ControlProperties.h +++ b/src/cascadia/inc/ControlProperties.h @@ -59,7 +59,6 @@ // All of these settings are defined in IControlSettings. #define CONTROL_SETTINGS(X) \ X(winrt::hstring, ProfileName) \ - X(winrt::hstring, ProfileSource) \ X(winrt::guid, SessionId) \ X(bool, EnableUnfocusedAcrylic, false) \ X(winrt::hstring, Padding, DEFAULT_PADDING) \ @@ -85,4 +84,5 @@ X(bool, UseBackgroundImageForWindow, false) \ X(bool, ShowMarks, false) \ X(winrt::Microsoft::Terminal::Control::CopyFormat, CopyFormatting, 0) \ - X(bool, RightClickContextMenu, false) + X(bool, RightClickContextMenu, false) \ + X(winrt::Microsoft::Terminal::Control::PathTranslationStyle, PathTranslationStyle, winrt::Microsoft::Terminal::Control::PathTranslationStyle::None)