Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into feature/llm
Browse files Browse the repository at this point in the history
  • Loading branch information
consvc committed Aug 9, 2024
2 parents c8b9764 + edfa3ea commit d49b2e4
Show file tree
Hide file tree
Showing 52 changed files with 360 additions and 389 deletions.
3 changes: 2 additions & 1 deletion .github/actions/spelling/expect/expect.txt
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ BTNFACE
bufferout
buffersize
buflen
buildtransitive
buildsystems
buildtransitive
BValue
bytebuffer
cac
Expand Down Expand Up @@ -2141,6 +2141,7 @@ XBUTTONDOWN
XBUTTONUP
XCast
XCENTER
xchar
xcopy
XCount
xdy
Expand Down
10 changes: 4 additions & 6 deletions src/cascadia/TerminalApp/AppActionHandlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -927,10 +927,8 @@ namespace winrt::TerminalApp::implementation

// Build the commandline to pass to wt for this set of NewTerminalArgs
// `-w -1` will ensure a new window is created.
winrt::hstring cmdline{
fmt::format(L"-w -1 new-tab {}",
terminalArgs.ToCommandline().c_str())
};
const auto commandline = terminalArgs.ToCommandline();
winrt::hstring cmdline{ fmt::format(FMT_COMPILE(L"-w -1 new-tab {}"), commandline) };

// Build the args to ShellExecuteEx. We need to use ShellExecuteEx so we
// can pass the SEE_MASK_NOASYNC flag. That flag allows us to safely
Expand Down Expand Up @@ -1124,14 +1122,14 @@ namespace winrt::TerminalApp::implementation
{
if (const auto& realArgs = args.ActionArgs().try_as<SearchForTextArgs>())
{
queryUrl = realArgs.QueryUrl().c_str();
queryUrl = std::wstring_view{ realArgs.QueryUrl() };
}
}

// use global default if query URL is unspecified
if (queryUrl.empty())
{
queryUrl = _settings.GlobalSettings().SearchWebDefaultQueryUrl().c_str();
queryUrl = std::wstring_view{ _settings.GlobalSettings().SearchWebDefaultQueryUrl() };
}

constexpr std::wstring_view queryToken{ L"%s" };
Expand Down
2 changes: 1 addition & 1 deletion src/cascadia/TerminalApp/AppLogic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ namespace winrt::TerminalApp::implementation
//
// So DON'T ~give a mouse a cookie~ take a static ref here.

const winrt::hstring modifiedBasename{ std::filesystem::path{ fileModified }.filename().c_str() };
const auto modifiedBasename = std::filesystem::path{ fileModified }.filename();

if (modifiedBasename == settingsBasename)
{
Expand Down
4 changes: 2 additions & 2 deletions src/cascadia/TerminalApp/CommandPalette.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ namespace winrt::TerminalApp::implementation
automationPeer.RaiseNotificationEvent(
Automation::Peers::AutomationNotificationKind::ActionCompleted,
Automation::Peers::AutomationNotificationProcessing::CurrentThenMostRecent,
fmt::format(std::wstring_view{ RS_(L"CommandPalette_NestedCommandAnnouncement") }, ParentCommandName()),
RS_fmt(L"CommandPalette_NestedCommandAnnouncement", ParentCommandName()),
L"CommandPaletteNestingLevelChanged" /* unique name for this notification category */);
}
}
Expand Down Expand Up @@ -879,7 +879,7 @@ namespace winrt::TerminalApp::implementation
Automation::Peers::AutomationNotificationKind::ActionCompleted,
Automation::Peers::AutomationNotificationProcessing::ImportantMostRecent,
currentNeedleHasResults ?
winrt::hstring{ fmt::format(std::wstring_view{ RS_(L"CommandPalette_MatchesAvailable") }, _filteredActions.Size()) } :
winrt::hstring{ RS_fmt(L"CommandPalette_MatchesAvailable", _filteredActions.Size()) } :
NoMatchesText(), // what to announce if results were found
L"CommandPaletteResultAnnouncement" /* unique name for this group of notifications */);
}
Expand Down
2 changes: 1 addition & 1 deletion src/cascadia/TerminalApp/Jumplist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ void Jumplist::_updateProfiles(IObjectCollection* jumplistItems, winrt::Windows:
for (const auto& profile : profiles)
{
// Craft the arguments following "wt.exe"
auto args = fmt::format(L"-p {}", to_hstring(profile.Guid()));
auto args = fmt::format(FMT_COMPILE(L"-p {}"), to_hstring(profile.Guid()));

// Create the shell link object for the profile
const auto normalizedIconPath{ _normalizeIconPath(profile.Icon()) };
Expand Down
2 changes: 1 addition & 1 deletion src/cascadia/TerminalApp/SnippetsPaneContent.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ namespace winrt::TerminalApp::implementation
{
if (const auto& sendInput{ command.ActionAndArgs().Args().try_as<winrt::Microsoft::Terminal::Settings::Model::SendInputArgs>() })
{
return winrt::hstring{ til::visualize_nonspace_control_codes(sendInput.Input().c_str()) };
return winrt::hstring{ til::visualize_nonspace_control_codes(std::wstring{ sendInput.Input() }) };
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/cascadia/TerminalApp/SuggestionsControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ namespace winrt::TerminalApp::implementation
automationPeer.RaiseNotificationEvent(
Automation::Peers::AutomationNotificationKind::ActionCompleted,
Automation::Peers::AutomationNotificationProcessing::CurrentThenMostRecent,
fmt::format(std::wstring_view{ RS_(L"SuggestionsControl_NestedCommandAnnouncement") }, ParentCommandName()),
RS_fmt(L"SuggestionsControl_NestedCommandAnnouncement", ParentCommandName()),
L"SuggestionsControlNestingLevelChanged" /* unique name for this notification category */);
}
}
Expand Down Expand Up @@ -810,7 +810,7 @@ namespace winrt::TerminalApp::implementation
Automation::Peers::AutomationNotificationKind::ActionCompleted,
Automation::Peers::AutomationNotificationProcessing::ImportantMostRecent,
currentNeedleHasResults ?
winrt::hstring{ fmt::format(std::wstring_view{ RS_(L"SuggestionsControl_MatchesAvailable") }, _filteredActions.Size()) } :
winrt::hstring{ RS_fmt(L"SuggestionsControl_MatchesAvailable", _filteredActions.Size()) } :
NoMatchesText(), // what to announce if results were found
L"SuggestionsControlResultAnnouncement" /* unique name for this group of notifications */);
}
Expand Down
2 changes: 1 addition & 1 deletion src/cascadia/TerminalApp/TabManagement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -985,7 +985,7 @@ namespace winrt::TerminalApp::implementation
const auto tabTitle = tab.Title();
autoPeer.RaiseNotificationEvent(Automation::Peers::AutomationNotificationKind::ActionCompleted,
Automation::Peers::AutomationNotificationProcessing::ImportantMostRecent,
fmt::format(std::wstring_view{ RS_(L"TerminalPage_TabMovedAnnouncement_Direction") }, tabTitle, newTabIndex + 1),
RS_fmt(L"TerminalPage_TabMovedAnnouncement_Direction", tabTitle, newTabIndex + 1),
L"TerminalPageMoveTabWithDirection" /* unique name for this notification category */);
}
}
Expand Down
18 changes: 9 additions & 9 deletions src/cascadia/TerminalApp/TerminalPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2321,7 +2321,7 @@ namespace winrt::TerminalApp::implementation
{
autoPeer.RaiseNotificationEvent(Automation::Peers::AutomationNotificationKind::ActionCompleted,
Automation::Peers::AutomationNotificationProcessing::ImportantMostRecent,
fmt::format(std::wstring_view{ RS_(L"TerminalPage_PaneMovedAnnouncement_ExistingWindow2") }, windowId),
RS_fmt(L"TerminalPage_PaneMovedAnnouncement_ExistingWindow2", windowId),
L"TerminalPageMovePaneToExistingWindow" /* unique name for this notification category */);
}
}
Expand Down Expand Up @@ -2356,7 +2356,7 @@ namespace winrt::TerminalApp::implementation
const auto tabTitle = targetTab->Title();
autoPeer.RaiseNotificationEvent(Automation::Peers::AutomationNotificationKind::ActionCompleted,
Automation::Peers::AutomationNotificationProcessing::ImportantMostRecent,
fmt::format(std::wstring_view{ RS_(L"TerminalPage_PaneMovedAnnouncement_ExistingTab") }, tabTitle),
RS_fmt(L"TerminalPage_PaneMovedAnnouncement_ExistingTab", tabTitle),
L"TerminalPageMovePaneToExistingTab" /* unique name for this notification category */);
}
}
Expand Down Expand Up @@ -2456,14 +2456,14 @@ namespace winrt::TerminalApp::implementation
{
autoPeer.RaiseNotificationEvent(Automation::Peers::AutomationNotificationKind::ActionCompleted,
Automation::Peers::AutomationNotificationProcessing::ImportantMostRecent,
fmt::format(std::wstring_view{ RS_(L"TerminalPage_TabMovedAnnouncement_NewWindow") }, tabTitle),
RS_fmt(L"TerminalPage_TabMovedAnnouncement_NewWindow", tabTitle),
L"TerminalPageMoveTabToNewWindow" /* unique name for this notification category */);
}
else
{
autoPeer.RaiseNotificationEvent(Automation::Peers::AutomationNotificationKind::ActionCompleted,
Automation::Peers::AutomationNotificationProcessing::ImportantMostRecent,
fmt::format(std::wstring_view{ RS_(L"TerminalPage_TabMovedAnnouncement_Default") }, tabTitle, windowId),
RS_fmt(L"TerminalPage_TabMovedAnnouncement_Default", tabTitle, windowId),
L"TerminalPageMoveTabToExistingWindow" /* unique name for this notification category */);
}
}
Expand Down Expand Up @@ -3004,7 +3004,7 @@ namespace winrt::TerminalApp::implementation
{
try
{
auto parsed = winrt::Windows::Foundation::Uri(eventArgs.Uri().c_str());
auto parsed = winrt::Windows::Foundation::Uri(eventArgs.Uri());
if (_IsUriSupported(parsed))
{
ShellExecute(nullptr, L"open", eventArgs.Uri().c_str(), nullptr, nullptr, SW_SHOWNORMAL);
Expand Down Expand Up @@ -4349,8 +4349,8 @@ namespace winrt::TerminalApp::implementation
winrt::hstring TerminalPage::KeyboardServiceDisabledText()
{
const auto serviceName{ _getTabletServiceName() };
const winrt::hstring text{ fmt::format(std::wstring_view(RS_(L"KeyboardServiceWarningText")), serviceName) };
return text;
const auto text{ RS_fmt(L"KeyboardServiceWarningText", serviceName) };
return winrt::hstring{ text };
}

// Method Description:
Expand Down Expand Up @@ -4640,7 +4640,7 @@ namespace winrt::TerminalApp::implementation

// Build the commandline to pass to wt for this set of NewTerminalArgs
auto cmdline{
fmt::format(L"new-tab {}", newTerminalArgs.ToCommandline().c_str())
fmt::format(FMT_COMPILE(L"new-tab {}"), newTerminalArgs.ToCommandline())
};

wil::unique_process_information pi;
Expand Down Expand Up @@ -5394,7 +5394,7 @@ namespace winrt::TerminalApp::implementation
{
// `this` is safe to use in here.

_sendDraggedTabToWindow(winrt::hstring{ fmt::format(L"{}", args.TargetWindow()) },
_sendDraggedTabToWindow(winrt::to_hstring(args.TargetWindow()),
args.TabIndex(),
std::nullopt);
}
Expand Down
2 changes: 1 addition & 1 deletion src/cascadia/TerminalApp/TerminalTab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1873,7 +1873,7 @@ namespace winrt::TerminalApp::implementation
const auto profileName{ control.Settings().ProfileName() };
if (profileName != Title())
{
return fmt::format(L"{}: {}", profileName, Title()).data();
return winrt::hstring{ fmt::format(FMT_COMPILE(L"{}: {}"), profileName, Title()) };
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/cascadia/TerminalApp/TerminalWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1362,7 +1362,7 @@ namespace winrt::TerminalApp::implementation
// - a string for displaying the name of the window.
winrt::hstring WindowProperties::WindowIdForDisplay() const noexcept
{
return winrt::hstring{ fmt::format(L"{}: {}",
return winrt::hstring{ fmt::format(FMT_COMPILE(L"{}: {}"),
std::wstring_view(RS_(L"WindowIdLabel")),
_WindowId) };
}
Expand All @@ -1376,7 +1376,7 @@ namespace winrt::TerminalApp::implementation
winrt::hstring WindowProperties::WindowNameForDisplay() const noexcept
{
return _WindowName.empty() ?
winrt::hstring{ fmt::format(L"<{}>", RS_(L"UnnamedWindowName")) } :
winrt::hstring{ fmt::format(FMT_COMPILE(L"<{}>"), RS_(L"UnnamedWindowName")) } :
_WindowName;
}

Expand Down
31 changes: 17 additions & 14 deletions src/cascadia/TerminalConnection/AzureConnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ static constexpr winrt::guid AzureConnectionType = { 0xd9fcfdfa, 0xa479, 0x412c,

static inline std::wstring _colorize(const unsigned int colorCode, const std::wstring_view text)
{
return fmt::format(L"\x1b[{0}m{1}\x1b[m", colorCode, text);
return fmt::format(FMT_COMPILE(L"\x1b[{0}m{1}\x1b[m"), colorCode, text);
}

// Takes N resource names, loads the first one as a format string, and then
Expand All @@ -47,15 +47,18 @@ static inline std::wstring _colorize(const unsigned int colorCode, const std::ws
template<typename... Args>
static inline std::wstring _formatResWithColoredUserInputOptions(const std::wstring_view resourceKey, Args&&... args)
{
return fmt::format(std::wstring_view{ GetLibraryResourceString(resourceKey) }, (_colorize(USER_INPUT_COLOR, GetLibraryResourceString(args)))...);
const auto format = GetLibraryResourceString(resourceKey);
return fmt::format(fmt::runtime(std::wstring_view{ format }), (_colorize(USER_INPUT_COLOR, GetLibraryResourceString(args)))...);
}

static inline std::wstring _formatTenant(int tenantNumber, const Tenant& tenant)
{
return fmt::format(std::wstring_view{ RS_(L"AzureIthTenant") },
_colorize(USER_INPUT_COLOR, std::to_wstring(tenantNumber)),
_colorize(USER_INFO_COLOR, tenant.DisplayName.value_or(std::wstring{ RS_(L"AzureUnknownTenantName") })),
tenant.DefaultDomain.value_or(tenant.ID)); // use the domain name if possible, ID if not.
return RS_fmt(
L"AzureIthTenant",
_colorize(USER_INPUT_COLOR, std::to_wstring(tenantNumber)),
_colorize(USER_INFO_COLOR, tenant.DisplayName.value_or(std::wstring{ RS_(L"AzureUnknownTenantName") })),
tenant.DefaultDomain.value_or(tenant.ID) // use the domain name if possible, ID if not.
);
}

namespace winrt::Microsoft::Terminal::TerminalConnection::implementation
Expand Down Expand Up @@ -244,7 +247,7 @@ namespace winrt::Microsoft::Terminal::TerminalConnection::implementation
}
else // We only transition to Connected when we've established the websocket.
{
auto uri{ fmt::format(L"{}terminals/{}/size?cols={}&rows={}&version=2019-01-01", _cloudShellUri, _terminalID, columns, rows) };
auto uri{ fmt::format(FMT_COMPILE(L"{}terminals/{}/size?cols={}&rows={}&version=2019-01-01"), _cloudShellUri, _terminalID, columns, rows) };

WWH::HttpStringContent content{
L"",
Expand Down Expand Up @@ -851,7 +854,7 @@ namespace winrt::Microsoft::Terminal::TerminalConnection::implementation
// - the response to the device code flow initiation
WDJ::JsonObject AzureConnection::_GetDeviceCode()
{
auto uri{ fmt::format(L"{}common/oauth2/devicecode", _loginUri) };
auto uri{ fmt::format(FMT_COMPILE(L"{}common/oauth2/devicecode"), _loginUri) };
WWH::HttpFormUrlEncodedContent content{
std::unordered_map<winrt::hstring, winrt::hstring>{
{ winrt::hstring{ L"client_id" }, winrt::hstring{ AzureClientID } },
Expand All @@ -872,7 +875,7 @@ namespace winrt::Microsoft::Terminal::TerminalConnection::implementation
// - else, throw an exception
WDJ::JsonObject AzureConnection::_WaitForUser(const winrt::hstring& deviceCode, int pollInterval, int expiresIn)
{
auto uri{ fmt::format(L"{}common/oauth2/token", _loginUri) };
auto uri{ fmt::format(FMT_COMPILE(L"{}common/oauth2/token"), _loginUri) };
WWH::HttpFormUrlEncodedContent content{
std::unordered_map<winrt::hstring, winrt::hstring>{
{ winrt::hstring{ L"grant_type" }, winrt::hstring{ L"device_code" } },
Expand Down Expand Up @@ -923,7 +926,7 @@ namespace winrt::Microsoft::Terminal::TerminalConnection::implementation
// - the response which contains a list of the user's Azure tenants
void AzureConnection::_PopulateTenantList()
{
auto uri{ fmt::format(L"{}tenants?api-version=2020-01-01", _resourceUri) };
auto uri{ fmt::format(FMT_COMPILE(L"{}tenants?api-version=2020-01-01"), _resourceUri) };

// Send the request and return the response as a json value
auto tenantResponse{ _SendRequestReturningJson(uri, nullptr) };
Expand All @@ -939,7 +942,7 @@ namespace winrt::Microsoft::Terminal::TerminalConnection::implementation
// - the response with the new tokens
void AzureConnection::_RefreshTokens()
{
auto uri{ fmt::format(L"{}{}/oauth2/token", _loginUri, _currentTenant->ID) };
auto uri{ fmt::format(FMT_COMPILE(L"{}{}/oauth2/token"), _loginUri, _currentTenant->ID) };
WWH::HttpFormUrlEncodedContent content{
std::unordered_map<winrt::hstring, winrt::hstring>{
{ winrt::hstring{ L"grant_type" }, winrt::hstring{ L"refresh_token" } },
Expand All @@ -962,7 +965,7 @@ namespace winrt::Microsoft::Terminal::TerminalConnection::implementation
// - the user's cloud shell settings
WDJ::JsonObject AzureConnection::_GetCloudShellUserSettings()
{
auto uri{ fmt::format(L"{}providers/Microsoft.Portal/userSettings/cloudconsole?api-version=2023-02-01-preview", _resourceUri) };
auto uri{ fmt::format(FMT_COMPILE(L"{}providers/Microsoft.Portal/userSettings/cloudconsole?api-version=2023-02-01-preview"), _resourceUri) };
return _SendRequestReturningJson(uri, nullptr);
}

Expand All @@ -972,7 +975,7 @@ namespace winrt::Microsoft::Terminal::TerminalConnection::implementation
// - the uri for the cloud shell
winrt::hstring AzureConnection::_GetCloudShell()
{
auto uri{ fmt::format(L"{}providers/Microsoft.Portal/consoles/default?api-version=2023-02-01-preview", _resourceUri) };
auto uri{ fmt::format(FMT_COMPILE(L"{}providers/Microsoft.Portal/consoles/default?api-version=2023-02-01-preview"), _resourceUri) };

WWH::HttpStringContent content{
LR"-({"properties": {"osType": "linux"}})-",
Expand All @@ -992,7 +995,7 @@ namespace winrt::Microsoft::Terminal::TerminalConnection::implementation
// - the uri for the terminal
winrt::hstring AzureConnection::_GetTerminal(const winrt::hstring& shellType)
{
auto uri{ fmt::format(L"{}terminals?cols={}&rows={}&version=2019-01-01&shell={}", _cloudShellUri, _initialCols, _initialRows, shellType) };
auto uri{ fmt::format(FMT_COMPILE(L"{}terminals?cols={}&rows={}&version=2019-01-01&shell={}"), _cloudShellUri, _initialCols, _initialRows, shellType) };

WWH::HttpStringContent content{
L"{}",
Expand Down
Loading

0 comments on commit d49b2e4

Please sign in to comment.