Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x-save the commandline in the current window #17758

Merged
merged 1 commit into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions src/cascadia/TerminalApp/AppCommandlineArgs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1020,10 +1020,21 @@ void AppCommandlineArgs::ValidateStartupCommands()
// handoff connection from the operating system.
if (!_isHandoffListener)
{
// If we only have a single x-save command, then set our target to the
// current terminal window. This will prevent us from spawning a new
// window just to save the commandline.
if (_startupActions.size() == 1 &&
_startupActions.front().Action() == ShortcutAction::SaveSnippet &&
_windowTarget.empty())
{
_windowTarget = "0";
}
// If we parsed no commands, or the first command we've parsed is not a new
// tab action, prepend a new-tab command to the front of the list.
if (_startupActions.empty() ||
_startupActions.front().Action() != ShortcutAction::NewTab)
// (also, we don't need to do this if the only action is a x-save)
else if (_startupActions.empty() ||
(_startupActions.front().Action() != ShortcutAction::NewTab &&
_startupActions.front().Action() != ShortcutAction::SaveSnippet))
{
// Build the NewTab action from the values we've parsed on the commandline.
NewTerminalArgs newTerminalArgs{};
Expand Down
4 changes: 4 additions & 0 deletions src/cascadia/TerminalApp/AppLogic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,10 @@ namespace winrt::TerminalApp::implementation
return winrt::make<FindTargetWindowResult>(WindowingBehaviorUseNone);
}

// Validate the args now. This will make sure that in the case of a
// single x-save command, we toss that commandline to the current
// terminal window
appArgs.ValidateStartupCommands();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yikes that validate means "change"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and apparently "partially parse"! AppCommandlineArgs.cpp R1044

const std::string parsedTarget{ appArgs.GetTargetWindow() };

// If the user did not provide any value on the commandline,
Expand Down
Loading