Remove ProfileName from the surface of CoreSettings (#19261)

You know how much I hate squirreling away information on objects we have
to pass halfway across the universe just to get back.

In this case, `StartingTitle` will always be the name of the profile. We
only used ProfileName in places where we _needed a Title_, so this makes
it much more obvious what we're doing.
This commit is contained in:
Dustin L. Howett 2025-08-20 17:03:47 -05:00 committed by GitHub
parent 642a2aa41e
commit 68b723c16c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 13 additions and 19 deletions

View File

@ -1161,11 +1161,13 @@ void Pane::SetActive()
// focused, else the profile of the last control to be focused
Profile Pane::GetFocusedProfile()
{
auto lastFocused = GetActivePane();
if (auto lastFocused{ GetActivePane() })
{
if (const auto& terminalPane{ lastFocused->_getTerminalContent() })
{
return terminalPane.GetProfile();
}
}
return nullptr;
}

View File

@ -2127,9 +2127,9 @@ namespace winrt::TerminalApp::implementation
// - The value to populate in the title run of the tool tip
winrt::hstring Tab::_CreateToolTipTitle()
{
if (const auto& control{ GetActiveTerminalControl() })
if (const auto profile{ GetFocusedProfile() })
{
const auto profileName{ control.Settings().ProfileName() };
const auto profileName{ profile.Name() };
if (profileName != Title())
{
return winrt::hstring{ fmt::format(FMT_COMPILE(L"{}: {}"), profileName, Title()) };

View File

@ -38,8 +38,6 @@ namespace Microsoft.Terminal.Control
interface IControlSettings requires Microsoft.Terminal.Core.ICoreSettings,
Microsoft.Terminal.Control.IControlAppearance
{
String ProfileName;
Boolean EnableUnfocusedAcrylic { get; };
Guid SessionId { get; };
ScrollbarState ScrollState { get; };

View File

@ -2610,9 +2610,9 @@ namespace winrt::Microsoft::Terminal::Control::implementation
return _core.Title();
}
hstring TermControl::GetProfileName() const
hstring TermControl::GetStartingTitle() const
{
return _core.Settings().ProfileName();
return _core.Settings().StartingTitle();
}
hstring TermControl::WorkingDirectory() const

View File

@ -58,7 +58,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
uint64_t ContentId() const;
hstring GetProfileName() const;
hstring GetStartingTitle() const;
bool CopySelectionToClipboard(bool dismissSelection, bool singleLine, bool withControlSequences, const CopyFormat formats);
void PasteTextFromClipboard();

View File

@ -308,14 +308,14 @@ namespace winrt::Microsoft::Terminal::Control::implementation
// fall back to title if profile name is empty
if (auto control{ _termControl.get() })
{
const auto profileName = control->GetProfileName();
if (profileName.empty())
const auto originalName = control->GetStartingTitle();
if (originalName.empty())
{
return control->Title();
}
else
{
return profileName;
return originalName;
}
}

View File

@ -297,9 +297,6 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
_AltGrAliasing = profile.AltGrAliasing();
_AnswerbackMessage = profile.AnswerbackMessage();
// Fill in the remaining properties from the profile
_ProfileName = profile.Name();
const auto fontInfo = profile.FontInfo();
_FontFace = fontInfo.FontFace();
_FontSize = fontInfo.FontSize();

View File

@ -121,8 +121,6 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
// ------------------------ End of Core Settings -----------------------
INHERITABLE_SETTING(Model::TerminalSettings, hstring, ProfileName);
INHERITABLE_SETTING(Model::TerminalSettings, guid, SessionId);
INHERITABLE_SETTING(Model::TerminalSettings, bool, EnableUnfocusedAcrylic, false);
INHERITABLE_SETTING(Model::TerminalSettings, bool, UseAcrylic, false);

View File

@ -60,7 +60,6 @@
// --------------------------- Control Settings ---------------------------
// All of these settings are defined in IControlSettings.
#define CONTROL_SETTINGS(X) \
X(winrt::hstring, ProfileName) \
X(winrt::guid, SessionId) \
X(bool, EnableUnfocusedAcrylic, false) \
X(winrt::hstring, Padding, DEFAULT_PADDING) \