Merge 96b2b2f5b3
into f2386de422
This commit is contained in:
commit
dad270bc07
|
@ -337,6 +337,7 @@
|
|||
"toggleShaderEffects",
|
||||
"wt",
|
||||
"quit",
|
||||
"restoreLastClosed",
|
||||
"unbound"
|
||||
],
|
||||
"type": "string"
|
||||
|
|
|
@ -75,6 +75,22 @@ namespace winrt::TerminalApp::implementation
|
|||
args.Handled(true);
|
||||
}
|
||||
|
||||
void TerminalPage::_HandleRestoreLastClosed(const IInspectable& /*sender*/,
|
||||
const ActionEventArgs& args)
|
||||
{
|
||||
if (_previouslyClosedPanesAndTabs.size() > 0)
|
||||
{
|
||||
const auto restoreActions = _previouslyClosedPanesAndTabs.back();
|
||||
for (const auto& action : restoreActions)
|
||||
{
|
||||
_actionDispatch->DoAction(action);
|
||||
}
|
||||
_previouslyClosedPanesAndTabs.pop_back();
|
||||
|
||||
args.Handled(true);
|
||||
}
|
||||
}
|
||||
|
||||
void TerminalPage::_HandleCloseWindow(const IInspectable& /*sender*/,
|
||||
const ActionEventArgs& args)
|
||||
{
|
||||
|
|
|
@ -408,6 +408,23 @@ namespace winrt::TerminalApp::implementation
|
|||
co_return;
|
||||
}
|
||||
}
|
||||
|
||||
if (const auto terminalTab = _GetTerminalTabImpl(tab))
|
||||
{
|
||||
const auto actions = terminalTab->BuildStartupActions();
|
||||
|
||||
_previouslyClosedPanesAndTabs.emplace_back(std::move(actions));
|
||||
}
|
||||
else if (tab.try_as<SettingsTab>())
|
||||
{
|
||||
ActionAndArgs action;
|
||||
action.Action(ShortcutAction::OpenSettings);
|
||||
OpenSettingsArgs args{ SettingsTarget::SettingsUI };
|
||||
action.Args(args);
|
||||
|
||||
_previouslyClosedPanesAndTabs.emplace_back(std::vector{ std::move(action) });
|
||||
}
|
||||
|
||||
_RemoveTab(tab);
|
||||
}
|
||||
|
||||
|
@ -710,6 +727,31 @@ namespace winrt::TerminalApp::implementation
|
|||
});
|
||||
}
|
||||
|
||||
// Just make sure we don't get infinitely large, but still
|
||||
// maintain a large replay buffer.
|
||||
if (const auto size = _previouslyClosedPanesAndTabs.size(); size > 100)
|
||||
{
|
||||
const auto it = _previouslyClosedPanesAndTabs.begin();
|
||||
_previouslyClosedPanesAndTabs.erase(it, it + (size - 100));
|
||||
}
|
||||
|
||||
// Build the list of actions to recreate the closed pane,
|
||||
// BuildStartupActions returns the "first" pane and the rest of
|
||||
// its actions are assuming that first pane has been created first.
|
||||
// This doesn't handle refocusing anything in particular, the
|
||||
// result will be that the last pane created is focused. In the
|
||||
// case of a single pane that is the desired behavior anyways.
|
||||
auto state = pane->BuildStartupActions(0, 1);
|
||||
{
|
||||
ActionAndArgs splitPaneAction{};
|
||||
splitPaneAction.Action(ShortcutAction::SplitPane);
|
||||
SplitPaneArgs splitPaneArgs{ SplitDirection::Automatic, state.firstPane->GetTerminalArgsForPane() };
|
||||
splitPaneAction.Args(splitPaneArgs);
|
||||
|
||||
state.args.emplace(state.args.begin(), std::move(splitPaneAction));
|
||||
}
|
||||
_previouslyClosedPanesAndTabs.emplace_back(std::move(state.args));
|
||||
|
||||
pane->Close();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -188,6 +188,8 @@ namespace winrt::TerminalApp::implementation
|
|||
std::optional<int> _rearrangeTo{};
|
||||
bool _removing{ false };
|
||||
|
||||
std::vector<std::vector<Microsoft::Terminal::Settings::Model::ActionAndArgs>> _previouslyClosedPanesAndTabs{};
|
||||
|
||||
uint32_t _systemRowsToScroll{ DefaultRowsToScroll };
|
||||
|
||||
// use a weak reference to prevent circular dependency with AppLogic
|
||||
|
|
|
@ -69,6 +69,7 @@ static constexpr std::string_view OpenSystemMenuKey{ "openSystemMenu" };
|
|||
static constexpr std::string_view ClearBufferKey{ "clearBuffer" };
|
||||
static constexpr std::string_view MultipleActionsKey{ "multipleActions" };
|
||||
static constexpr std::string_view QuitKey{ "quit" };
|
||||
static constexpr std::string_view RestoreLastClosedKey{ "restoreLastClosed" };
|
||||
|
||||
static constexpr std::string_view ActionKey{ "action" };
|
||||
|
||||
|
@ -374,6 +375,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
|
|||
{ ShortcutAction::ClearBuffer, L"" }, // Intentionally omitted, must be generated by GenerateName
|
||||
{ ShortcutAction::MultipleActions, L"" }, // Intentionally omitted, must be generated by GenerateName
|
||||
{ ShortcutAction::Quit, RS_(L"QuitCommandKey") },
|
||||
{ ShortcutAction::RestoreLastClosed, RS_(L"RestoreLastClosedCommandKey") },
|
||||
};
|
||||
}();
|
||||
|
||||
|
|
|
@ -82,7 +82,8 @@
|
|||
ON_ALL_ACTIONS(OpenSystemMenu) \
|
||||
ON_ALL_ACTIONS(ClearBuffer) \
|
||||
ON_ALL_ACTIONS(MultipleActions) \
|
||||
ON_ALL_ACTIONS(Quit)
|
||||
ON_ALL_ACTIONS(Quit) \
|
||||
ON_ALL_ACTIONS(RestoreLastClosed)
|
||||
|
||||
#define ALL_SHORTCUT_ACTIONS_WITH_ARGS \
|
||||
ON_ALL_ACTIONS_WITH_ARGS(AdjustFontSize) \
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
@ -478,4 +478,7 @@
|
|||
<data name="QuitCommandKey" xml:space="preserve">
|
||||
<value>Quit the Terminal</value>
|
||||
</data>
|
||||
<data name="RestoreLastClosedCommandKey" xml:space="preserve">
|
||||
<value>Restore the last closed pane or tab</value>
|
||||
</data>
|
||||
</root>
|
||||
|
|
|
@ -305,6 +305,7 @@
|
|||
{ "command": "quakeMode", "keys":"win+sc(41)" },
|
||||
{ "command": "openSystemMenu", "keys": "alt+space" },
|
||||
{ "command": "quit" },
|
||||
{ "command": "restoreLastClosed"},
|
||||
|
||||
// Tab Management
|
||||
// "command": "closeTab" is unbound by default.
|
||||
|
|
Loading…
Reference in a new issue