mirror of
https://github.com/microsoft/terminal.git
synced 2026-05-19 03:10:49 +00:00
JsonSource->Filename; remove deep copy of fragments & generators
This commit is contained in:
@@ -100,7 +100,7 @@
|
||||
Margin="0,4,0,0"
|
||||
HorizontalAlignment="Stretch"
|
||||
HorizontalContentAlignment="Stretch"
|
||||
Header="{x:Bind Fragment.JsonSource}">
|
||||
Header="{x:Bind Fragment.Filename}">
|
||||
<ScrollViewer Style="{StaticResource CodeBlockScrollViewerStyle}">
|
||||
<TextBlock Style="{StaticResource CodeBlockStyle}"
|
||||
Text="{x:Bind Fragment.Json}" />
|
||||
|
||||
@@ -114,27 +114,10 @@ Model::CascadiaSettings CascadiaSettings::Copy() const
|
||||
settings->_allProfiles = winrt::single_threaded_observable_vector(std::move(allProfiles));
|
||||
settings->_activeProfiles = winrt::single_threaded_observable_vector(std::move(activeProfiles));
|
||||
|
||||
// copy fragment extensions
|
||||
{
|
||||
std::vector<Model::FragmentSettings> fragmentExtensions;
|
||||
fragmentExtensions.reserve(_fragmentExtensions.Size());
|
||||
for (const auto& fragment : _fragmentExtensions)
|
||||
{
|
||||
fragmentExtensions.emplace_back(get_self<FragmentSettings>(fragment)->Copy());
|
||||
}
|
||||
settings->_fragmentExtensions = winrt::single_threaded_vector(std::move(fragmentExtensions));
|
||||
}
|
||||
|
||||
// copy dynamic profile generators
|
||||
{
|
||||
std::vector<Model::FragmentSettings> dynamicProfileGenerators;
|
||||
dynamicProfileGenerators.reserve(_dynamicProfileGeneratorExtensions.Size());
|
||||
for (const auto& fragment : _dynamicProfileGeneratorExtensions)
|
||||
{
|
||||
dynamicProfileGenerators.emplace_back(get_self<FragmentSettings>(fragment)->Copy());
|
||||
}
|
||||
settings->_dynamicProfileGeneratorExtensions = winrt::single_threaded_vector(std::move(dynamicProfileGenerators));
|
||||
}
|
||||
// fragment extensions and dynamic profile generators don't need a deep clone
|
||||
// because they're fully immutable. We can just copy the reference over instead.
|
||||
settings->_fragmentExtensions = _fragmentExtensions;
|
||||
settings->_dynamicProfileGeneratorExtensions = _dynamicProfileGeneratorExtensions;
|
||||
}
|
||||
|
||||
// load errors
|
||||
@@ -153,46 +136,6 @@ Model::CascadiaSettings CascadiaSettings::Copy() const
|
||||
return *settings;
|
||||
}
|
||||
|
||||
Model::FragmentSettings FragmentSettings::Copy() const
|
||||
{
|
||||
auto fragment{ winrt::make_self<FragmentSettings>(_source, _json, _jsonSource, _scope) };
|
||||
|
||||
if (_modifiedProfiles)
|
||||
{
|
||||
std::vector<Model::FragmentProfileEntry> modifiedProfiles;
|
||||
modifiedProfiles.reserve(_modifiedProfiles.Size());
|
||||
for (const auto& entry : _modifiedProfiles)
|
||||
{
|
||||
modifiedProfiles.emplace_back(winrt::make<FragmentProfileEntry>(entry.ProfileGuid(), entry.Json()));
|
||||
}
|
||||
fragment->_modifiedProfiles = winrt::single_threaded_vector(std::move(modifiedProfiles));
|
||||
}
|
||||
|
||||
if (_newProfiles)
|
||||
{
|
||||
std::vector<Model::FragmentProfileEntry> newProfiles;
|
||||
newProfiles.reserve(_newProfiles.Size());
|
||||
for (const auto& entry : _newProfiles)
|
||||
{
|
||||
newProfiles.emplace_back(winrt::make<FragmentProfileEntry>(entry.ProfileGuid(), entry.Json()));
|
||||
}
|
||||
fragment->_newProfiles = winrt::single_threaded_vector(std::move(newProfiles));
|
||||
}
|
||||
|
||||
if (_colorSchemes)
|
||||
{
|
||||
std::vector<Model::FragmentColorSchemeEntry> colorSchemes;
|
||||
colorSchemes.reserve(_colorSchemes.Size());
|
||||
for (const auto& entry : _colorSchemes)
|
||||
{
|
||||
colorSchemes.emplace_back(winrt::make<FragmentColorSchemeEntry>(entry.ColorSchemeName(), entry.Json()));
|
||||
}
|
||||
fragment->_colorSchemes = winrt::single_threaded_vector(std::move(colorSchemes));
|
||||
}
|
||||
|
||||
return *fragment;
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Finds a profile that matches the given GUID. If there is no profile in this
|
||||
// settings object that matches, returns nullptr.
|
||||
|
||||
@@ -243,18 +243,16 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
|
||||
struct FragmentSettings : FragmentSettingsT<FragmentSettings>
|
||||
{
|
||||
public:
|
||||
FragmentSettings(hstring source, hstring json, hstring jsonSource, FragmentScope scope) :
|
||||
FragmentSettings(hstring source, hstring json, hstring filename, FragmentScope scope) :
|
||||
_source{ source },
|
||||
_json{ json },
|
||||
_jsonSource{ jsonSource },
|
||||
_filename{ filename },
|
||||
_scope{ scope } {}
|
||||
|
||||
Model::FragmentSettings Copy() const;
|
||||
|
||||
hstring Source() const noexcept { return _source; }
|
||||
FragmentScope Scope() const noexcept { return _scope; }
|
||||
hstring Json() const noexcept { return _json; }
|
||||
hstring JsonSource() const noexcept { return _jsonSource; }
|
||||
hstring Filename() const noexcept { return _filename; }
|
||||
Windows::Foundation::Collections::IVector<Model::FragmentProfileEntry> ModifiedProfiles() const noexcept { return _modifiedProfiles; }
|
||||
void ModifiedProfiles(const Windows::Foundation::Collections::IVector<Model::FragmentProfileEntry>& modifiedProfiles) noexcept { _modifiedProfiles = modifiedProfiles; }
|
||||
Windows::Foundation::Collections::IVector<Model::FragmentProfileEntry> NewProfiles() const noexcept { return _newProfiles; }
|
||||
@@ -270,7 +268,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
|
||||
private:
|
||||
hstring _source;
|
||||
hstring _json;
|
||||
hstring _jsonSource;
|
||||
hstring _filename;
|
||||
FragmentScope _scope;
|
||||
Windows::Foundation::Collections::IVector<Model::FragmentProfileEntry> _modifiedProfiles;
|
||||
Windows::Foundation::Collections::IVector<Model::FragmentProfileEntry> _newProfiles;
|
||||
|
||||
@@ -83,7 +83,7 @@ namespace Microsoft.Terminal.Settings.Model
|
||||
String Source { get; };
|
||||
FragmentScope Scope { get; };
|
||||
String Json { get; };
|
||||
String JsonSource { get; };
|
||||
String Filename { get; };
|
||||
Windows.Foundation.Collections.IVectorView<FragmentProfileEntry> ModifiedProfilesView { get; };
|
||||
Windows.Foundation.Collections.IVectorView<FragmentProfileEntry> NewProfilesView { get; };
|
||||
Windows.Foundation.Collections.IVectorView<FragmentColorSchemeEntry> ColorSchemesView { get; };
|
||||
|
||||
Reference in New Issue
Block a user