Add setting for customizable delimiter for file drag-and-drop (#19799)

## Summary of the Pull Request
This PR introduces a new profile setting, `dragDropDelimiter`, which
allows users to configure the string separator used when dragging and
dropping multiple files into the terminal. The default behavior remains
a single space (`" "`) for backward compatibility.

## References and Relevant Issues
* Closes #19565

## Detailed Description of the Pull Request / Additional comments
**Implementation Details:**
* **Settings:** Added `DragDropDelimiter` to `MTSMSettings.h` and
`Profile.idl`.
* **Control:** Wired the setting through `ControlProperties.h` so the
terminal logic can see it.
* **Logic:** Updated `TermControl::OnDrop` to use the new delimiter when
joining paths.
* **UI:** Added the text box in the Advanced Settings page and updated
the ViewModel.

## Validation Steps Performed
* **Manual Verification:**
    * Verified default behavior (space separator) works as before.
* Configured `dragDropDelimiter` to `", "`, `";"`, and custom strings in
`settings.json` and from settings UI.
    * Confirmed dropped files are joined correctly.
* **Build:** Validated that the solution builds cleanly.

## Notes for Reviewers
1. **Delimiter Length:** Currently, there is no limit on the maximum
length of the delimiter string. Let me know if this should be changed.
3.  **Localization:** I changed only `Resources/en-US` file.
4. **ViewModel:** In `ProfileViewModel.cpp`, I added the `else if` block
for the new setting, but left it empty because no other UI logic
currently depends on it.

## PR Checklist
- [x] Closes #19565
- [ ] Documentation updated
- [x] Schema updated (if necessary)
This commit is contained in:
Vallabh Mahajan
2026-03-30 23:08:01 +05:30
committed by GitHub
parent a1a43a4ff5
commit 69e4590bc5
11 changed files with 36 additions and 5 deletions

View File

@@ -3174,6 +3174,11 @@
"mingw"
],
"type": "string"
},
"dragDropDelimiter": {
"default": " ",
"description": "The delimiter used when dropping multiple files onto the terminal.",
"type": "string"
}
}
},

View File

@@ -76,6 +76,7 @@ namespace Microsoft.Terminal.Control
Boolean RepositionCursorWithMouse { get; };
PathTranslationStyle PathTranslationStyle { get; };
String DragDropDelimiter { get; };
// NOTE! When adding something here, make sure to update ControlProperties.h too!
};

View File

@@ -3060,7 +3060,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
// the full path of the file to our terminal connection. Like conhost, if
// the path contains a space, we'll wrap the path in quotes.
// - Unlike conhost, if multiple files are dropped onto the terminal, we'll
// write all the paths to the terminal, separated by spaces.
// write all the paths to the terminal, separated by the configured delimiter.
// Arguments:
// - e: The DragEventArgs from the Drop event
// Return Value:
@@ -3181,12 +3181,13 @@ namespace winrt::Microsoft::Terminal::Control::implementation
}
std::wstring allPathsString;
const auto delimiter{ _core.Settings().DragDropDelimiter() };
for (auto& fullPath : fullPaths)
{
// Join the paths with spaces
// Join the paths with the delimiter
if (!allPathsString.empty())
{
allPathsString += L" ";
allPathsString += delimiter;
}
const auto translationStyle{ _core.Settings().PathTranslationStyle() };

View File

@@ -353,6 +353,7 @@ namespace winrt::Microsoft::Terminal::Settings
_AllowVtChecksumReport = profile.AllowVtChecksumReport();
_AllowVtClipboardWrite = profile.AllowVtClipboardWrite();
_PathTranslationStyle = profile.PathTranslationStyle();
_DragDropDelimiter = profile.DragDropDelimiter();
}
// Method Description:

View File

@@ -145,6 +145,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
OBSERVABLE_PROJECTED_SETTING(_profile, AnswerbackMessage);
OBSERVABLE_PROJECTED_SETTING(_profile, RainbowSuggestions);
OBSERVABLE_PROJECTED_SETTING(_profile, PathTranslationStyle);
OBSERVABLE_PROJECTED_SETTING(_profile, DragDropDelimiter);
WINRT_PROPERTY(bool, IsBaseLayer, false);
WINRT_PROPERTY(bool, FocusDeleteButton, false);

View File

@@ -139,6 +139,7 @@ namespace Microsoft.Terminal.Settings.Editor
OBSERVABLE_PROJECTED_PROFILE_SETTING(String, AnswerbackMessage);
OBSERVABLE_PROJECTED_PROFILE_SETTING(Boolean, RainbowSuggestions);
OBSERVABLE_PROJECTED_PROFILE_SETTING(Microsoft.Terminal.Control.PathTranslationStyle, PathTranslationStyle);
OBSERVABLE_PROJECTED_PROFILE_SETTING(String, DragDropDelimiter);
OBSERVABLE_PROJECTED_PROFILE_SETTING(Boolean, AllowVtClipboardWrite);
}
}

View File

@@ -272,6 +272,16 @@
Style="{StaticResource ComboBoxSettingStyle}" />
</local:SettingContainer>
<!-- Drag Drop Delimiter -->
<local:SettingContainer x:Name="DragDropDelimiter"
x:Uid="Profile_DragDropDelimiter"
ClearSettingValue="{x:Bind Profile.ClearDragDropDelimiter}"
HasSettingValue="{x:Bind Profile.HasDragDropDelimiter, Mode=OneWay}"
SettingOverrideSource="{x:Bind Profile.DragDropDelimiterOverrideSource, Mode=OneWay}">
<TextBox Style="{StaticResource TextBoxSettingStyle}"
Text="{x:Bind Profile.DragDropDelimiter, Mode=TwoWay}" />
</local:SettingContainer>
</StackPanel>
</Grid>
</Page>

View File

@@ -2748,4 +2748,12 @@
<value>Type to filter icons</value>
<comment>Placeholder text for a text box to filter and select an icon.</comment>
</data>
</root>
<data name="Profile_DragDropDelimiter.Header" xml:space="preserve">
<value>Drag and drop delimiter</value>
<comment>Header for a control to set the delimiter used when dragging multiple files into the terminal.</comment>
</data>
<data name="Profile_DragDropDelimiter.HelpText" xml:space="preserve">
<value>This text will be inserted between the paths of multiple files dropped into the terminal.</value>
<comment>A description for what the "drag drop delimiter" setting does.</comment>
</data>
</root>

View File

@@ -108,6 +108,7 @@ Author(s):
X(bool, AllowVtChecksumReport, "compatibility.allowDECRQCRA", false) \
X(bool, AllowVtClipboardWrite, "compatibility.allowOSC52", true) \
X(bool, AllowKeypadMode, "compatibility.allowDECNKM", false) \
X(hstring, DragDropDelimiter, "dragDropDelimiter", L" ") \
X(Microsoft::Terminal::Control::PathTranslationStyle, PathTranslationStyle, "pathTranslationStyle", Microsoft::Terminal::Control::PathTranslationStyle::None)
// Intentionally omitted Profile settings:

View File

@@ -94,5 +94,6 @@ namespace Microsoft.Terminal.Settings.Model
INHERITABLE_PROFILE_SETTING(Boolean, AllowVtClipboardWrite);
INHERITABLE_PROFILE_SETTING(Microsoft.Terminal.Control.PathTranslationStyle, PathTranslationStyle);
INHERITABLE_PROFILE_SETTING(String, DragDropDelimiter);
}
}

View File

@@ -87,4 +87,5 @@
X(bool, ShowMarks, false) \
X(winrt::Microsoft::Terminal::Control::CopyFormat, CopyFormatting, 0) \
X(bool, RightClickContextMenu, false) \
X(winrt::Microsoft::Terminal::Control::PathTranslationStyle, PathTranslationStyle, winrt::Microsoft::Terminal::Control::PathTranslationStyle::None)
X(winrt::Microsoft::Terminal::Control::PathTranslationStyle, PathTranslationStyle, winrt::Microsoft::Terminal::Control::PathTranslationStyle::None) \
X(winrt::hstring, DragDropDelimiter, L" ")