mirror of
https://github.com/microsoft/terminal.git
synced 2026-04-06 14:19:45 +00:00
Compare commits
1 Commits
dev/lhecke
...
dev/migrie
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
941ef48cfe |
@@ -1360,7 +1360,7 @@ namespace winrt::TerminalApp::implementation
|
||||
// their settings file. Ask the ActionMap for those.
|
||||
if (WI_IsFlagSet(source, SuggestionsSource::Tasks))
|
||||
{
|
||||
const auto tasks = _settings.GlobalSettings().ActionMap().FilterToSendInput(currentCommandline);
|
||||
const auto tasks = _settings.GlobalSettings().ActionMap().FilterToSendInput(currentCommandline, realArgs.Nesting());
|
||||
for (const auto& t : tasks)
|
||||
{
|
||||
commandsCollection.push_back(t);
|
||||
|
||||
@@ -216,8 +216,9 @@ protected: \
|
||||
X(CommandPaletteLaunchMode, LaunchMode, "launchMode", false, CommandPaletteLaunchMode::Action)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#define SUGGESTIONS_ARGS(X) \
|
||||
X(SuggestionsSource, Source, "source", false, SuggestionsSource::Tasks) \
|
||||
#define SUGGESTIONS_ARGS(X) \
|
||||
X(SuggestionsSource, Source, "source", false, SuggestionsSource::Tasks) \
|
||||
X(SuggestionsNesting, Nesting, "nesting", false, SuggestionsNesting::Enabled) \
|
||||
X(bool, UseCommandline, "useCommandline", false, false)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -122,6 +122,12 @@ namespace Microsoft.Terminal.Settings.Model
|
||||
All = 0xffffffff,
|
||||
};
|
||||
|
||||
enum SuggestionsNesting
|
||||
{
|
||||
Disabled,
|
||||
Enabled,
|
||||
};
|
||||
|
||||
interface INewContentArgs {
|
||||
String Type { get; };
|
||||
Boolean Equals(INewContentArgs other);
|
||||
@@ -343,8 +349,9 @@ namespace Microsoft.Terminal.Settings.Model
|
||||
[default_interface] runtimeclass SuggestionsArgs : IActionArgs
|
||||
{
|
||||
SuggestionsArgs();
|
||||
SuggestionsArgs(SuggestionsSource source, Boolean useCommandline);
|
||||
SuggestionsArgs(SuggestionsSource source, SuggestionsNesting nesting, Boolean useCommandline);
|
||||
SuggestionsSource Source { get; };
|
||||
SuggestionsNesting Nesting { get; };
|
||||
Boolean UseCommandline { get; };
|
||||
};
|
||||
|
||||
|
||||
@@ -806,7 +806,8 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
|
||||
}
|
||||
|
||||
IVector<Model::Command> _filterToSendInput(IMapView<hstring, Model::Command> nameMap,
|
||||
winrt::hstring currentCommandline)
|
||||
winrt::hstring currentCommandline,
|
||||
Model::SuggestionsNesting nesting)
|
||||
{
|
||||
auto results = winrt::single_threaded_vector<Model::Command>();
|
||||
|
||||
@@ -861,20 +862,30 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
|
||||
else if (command.HasNestedCommands())
|
||||
{
|
||||
// Look for any sendInput commands nested underneath us
|
||||
auto innerResults = _filterToSendInput(command.NestedCommands(), currentCommandline);
|
||||
auto innerResults = _filterToSendInput(command.NestedCommands(), currentCommandline, nesting);
|
||||
|
||||
if (innerResults.Size() > 0)
|
||||
{
|
||||
// This command did have at least one sendInput under it
|
||||
if (nesting == Model::SuggestionsNesting::Enabled)
|
||||
{
|
||||
// Create a new Command, which is a copy of this Command,
|
||||
// which only has SendInputs in it
|
||||
winrt::com_ptr<implementation::Command> cmdImpl;
|
||||
cmdImpl.copy_from(winrt::get_self<implementation::Command>(command));
|
||||
auto copy = cmdImpl->Copy();
|
||||
copy->NestedCommands(innerResults.GetView());
|
||||
|
||||
// Create a new Command, which is a copy of this Command,
|
||||
// which only has SendInputs in it
|
||||
winrt::com_ptr<implementation::Command> cmdImpl;
|
||||
cmdImpl.copy_from(winrt::get_self<implementation::Command>(command));
|
||||
auto copy = cmdImpl->Copy();
|
||||
copy->NestedCommands(innerResults.GetView());
|
||||
|
||||
results.Append(*copy);
|
||||
results.Append(*copy);
|
||||
}
|
||||
else if (nesting == Model::SuggestionsNesting::Disabled)
|
||||
{
|
||||
// Just add all the nested commands directly to the list we're going to return
|
||||
for (const auto& nested : innerResults)
|
||||
{
|
||||
results.Append(nested);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -883,8 +894,9 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
|
||||
}
|
||||
|
||||
IVector<Model::Command> ActionMap::FilterToSendInput(
|
||||
winrt::hstring currentCommandline)
|
||||
winrt::hstring currentCommandline,
|
||||
Model::SuggestionsNesting nesting)
|
||||
{
|
||||
return _filterToSendInput(NameMap(), currentCommandline);
|
||||
return _filterToSendInput(NameMap(), currentCommandline, nesting);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
|
||||
void ExpandCommands(const Windows::Foundation::Collections::IVectorView<Model::Profile>& profiles,
|
||||
const Windows::Foundation::Collections::IMapView<winrt::hstring, Model::ColorScheme>& schemes);
|
||||
|
||||
winrt::Windows::Foundation::Collections::IVector<Model::Command> FilterToSendInput(winrt::hstring currentCommandline);
|
||||
winrt::Windows::Foundation::Collections::IVector<Model::Command> FilterToSendInput(winrt::hstring currentCommandline, Model::SuggestionsNesting nesting);
|
||||
|
||||
private:
|
||||
Model::Command _GetActionByID(const winrt::hstring& actionID) const;
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace Microsoft.Terminal.Settings.Model
|
||||
|
||||
IVector<Command> ExpandedCommands { get; };
|
||||
|
||||
IVector<Command> FilterToSendInput(String CurrentCommandline);
|
||||
IVector<Command> FilterToSendInput(String CurrentCommandline, SuggestionsNesting nesting);
|
||||
};
|
||||
|
||||
[default_interface] runtimeclass ActionMap : IActionMapView
|
||||
|
||||
@@ -510,6 +510,14 @@ JSON_FLAG_MAPPER(::winrt::Microsoft::Terminal::Settings::Model::SuggestionsSourc
|
||||
};
|
||||
};
|
||||
|
||||
JSON_ENUM_MAPPER(::winrt::Microsoft::Terminal::Settings::Model::SuggestionsNesting)
|
||||
{
|
||||
JSON_MAPPINGS(2) = {
|
||||
pair_type{ "enabled", ValueType::Enabled },
|
||||
pair_type{ "disabled", ValueType::Disabled },
|
||||
};
|
||||
};
|
||||
|
||||
JSON_ENUM_MAPPER(::winrt::Microsoft::Terminal::Settings::Model::WindowingMode)
|
||||
{
|
||||
JSON_MAPPINGS(3) = {
|
||||
|
||||
Reference in New Issue
Block a user