mirror of
https://github.com/microsoft/terminal.git
synced 2025-12-11 04:38:24 -06:00
Open current working directory action. (#18013)
## Summary of the Pull Request Added open current directory action. ## References and Relevant Issues Need to set this: https://learn.microsoft.com/en-us/windows/terminal/tutorials/new-tab-same-directory ## Detailed Description of the Pull Request / Additional comments ## Validation Steps Performed - Ensure shell has been configured - Run "Open current working directory" action in command palette - File explorer opens the correct directory ## PR Checklist - [x] Closes #12859 - [ ] Tests added/passed - [ ] Documentation updated - If checked, please file a pull request on [our docs repo](https://github.com/MicrosoftDocs/terminal) and link it here: #xxx - [ ] Schema updated (if necessary)
This commit is contained in:
parent
89bc36c021
commit
7cdf9eeafb
@ -423,6 +423,7 @@
|
|||||||
"newWindow",
|
"newWindow",
|
||||||
"nextTab",
|
"nextTab",
|
||||||
"openAbout",
|
"openAbout",
|
||||||
|
"openCWD",
|
||||||
"openNewTabDropdown",
|
"openNewTabDropdown",
|
||||||
"openSettings",
|
"openSettings",
|
||||||
"openSystemMenu",
|
"openSystemMenu",
|
||||||
|
|||||||
@ -1128,6 +1128,16 @@ namespace winrt::TerminalApp::implementation
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TerminalPage::_HandleOpenCWD(const IInspectable& /*sender*/,
|
||||||
|
const ActionEventArgs& args)
|
||||||
|
{
|
||||||
|
if (const auto& control{ _GetActiveControl() })
|
||||||
|
{
|
||||||
|
control.OpenCWD();
|
||||||
|
args.Handled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void TerminalPage::_HandleGlobalSummon(const IInspectable& /*sender*/,
|
void TerminalPage::_HandleGlobalSummon(const IInspectable& /*sender*/,
|
||||||
const ActionEventArgs& args)
|
const ActionEventArgs& args)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1656,6 +1656,12 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
|||||||
SearchMissingCommand.raise(*this, make<implementation::SearchMissingCommandEventArgs>(hstring{ missingCommand }, bufferRow));
|
SearchMissingCommand.raise(*this, make<implementation::SearchMissingCommandEventArgs>(hstring{ missingCommand }, bufferRow));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ControlCore::OpenCWD()
|
||||||
|
{
|
||||||
|
const auto workingDirectory = WorkingDirectory();
|
||||||
|
ShellExecute(nullptr, nullptr, L"explorer", workingDirectory.c_str(), nullptr, SW_SHOW);
|
||||||
|
}
|
||||||
|
|
||||||
void ControlCore::ClearQuickFix()
|
void ControlCore::ClearQuickFix()
|
||||||
{
|
{
|
||||||
_cachedQuickFixes = nullptr;
|
_cachedQuickFixes = nullptr;
|
||||||
|
|||||||
@ -157,6 +157,8 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
|||||||
|
|
||||||
void ClearQuickFix();
|
void ClearQuickFix();
|
||||||
|
|
||||||
|
void OpenCWD();
|
||||||
|
|
||||||
#pragma region ICoreState
|
#pragma region ICoreState
|
||||||
const size_t TaskbarState() const noexcept;
|
const size_t TaskbarState() const noexcept;
|
||||||
const size_t TaskbarProgress() const noexcept;
|
const size_t TaskbarProgress() const noexcept;
|
||||||
|
|||||||
@ -178,6 +178,8 @@ namespace Microsoft.Terminal.Control
|
|||||||
Boolean ShouldShowSelectCommand();
|
Boolean ShouldShowSelectCommand();
|
||||||
Boolean ShouldShowSelectOutput();
|
Boolean ShouldShowSelectOutput();
|
||||||
|
|
||||||
|
void OpenCWD();
|
||||||
|
|
||||||
void ClearQuickFix();
|
void ClearQuickFix();
|
||||||
|
|
||||||
// These events are called from some background thread
|
// These events are called from some background thread
|
||||||
|
|||||||
@ -2675,6 +2675,11 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TermControl::OpenCWD()
|
||||||
|
{
|
||||||
|
_core.OpenCWD();
|
||||||
|
}
|
||||||
|
|
||||||
void TermControl::Close()
|
void TermControl::Close()
|
||||||
{
|
{
|
||||||
if (!_IsClosing())
|
if (!_IsClosing())
|
||||||
|
|||||||
@ -69,6 +69,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
|||||||
bool ExpandSelectionToWord();
|
bool ExpandSelectionToWord();
|
||||||
void RestoreFromPath(winrt::hstring path);
|
void RestoreFromPath(winrt::hstring path);
|
||||||
void PersistToPath(const winrt::hstring& path) const;
|
void PersistToPath(const winrt::hstring& path) const;
|
||||||
|
void OpenCWD();
|
||||||
void Close();
|
void Close();
|
||||||
Windows::Foundation::Size CharacterDimensions() const;
|
Windows::Foundation::Size CharacterDimensions() const;
|
||||||
Windows::Foundation::Size MinimumSize();
|
Windows::Foundation::Size MinimumSize();
|
||||||
|
|||||||
@ -97,6 +97,7 @@ namespace Microsoft.Terminal.Control
|
|||||||
void ClearBuffer(ClearBufferType clearType);
|
void ClearBuffer(ClearBufferType clearType);
|
||||||
void RestoreFromPath(String path);
|
void RestoreFromPath(String path);
|
||||||
void PersistToPath(String path);
|
void PersistToPath(String path);
|
||||||
|
void OpenCWD();
|
||||||
void Close();
|
void Close();
|
||||||
Windows.Foundation.Size CharacterDimensions { get; };
|
Windows.Foundation.Size CharacterDimensions { get; };
|
||||||
Windows.Foundation.Size MinimumSize { get; };
|
Windows.Foundation.Size MinimumSize { get; };
|
||||||
|
|||||||
@ -100,6 +100,7 @@ static constexpr std::string_view ToggleBroadcastInputKey{ "toggleBroadcastInput
|
|||||||
static constexpr std::string_view OpenScratchpadKey{ "experimental.openScratchpad" };
|
static constexpr std::string_view OpenScratchpadKey{ "experimental.openScratchpad" };
|
||||||
static constexpr std::string_view OpenAboutKey{ "openAbout" };
|
static constexpr std::string_view OpenAboutKey{ "openAbout" };
|
||||||
static constexpr std::string_view QuickFixKey{ "quickFix" };
|
static constexpr std::string_view QuickFixKey{ "quickFix" };
|
||||||
|
static constexpr std::string_view OpenCWDKey{ "openCWD" };
|
||||||
|
|
||||||
static constexpr std::string_view ActionKey{ "action" };
|
static constexpr std::string_view ActionKey{ "action" };
|
||||||
|
|
||||||
@ -437,6 +438,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
|
|||||||
{ ShortcutAction::OpenScratchpad, RS_(L"OpenScratchpadKey") },
|
{ ShortcutAction::OpenScratchpad, RS_(L"OpenScratchpadKey") },
|
||||||
{ ShortcutAction::OpenAbout, RS_(L"OpenAboutCommandKey") },
|
{ ShortcutAction::OpenAbout, RS_(L"OpenAboutCommandKey") },
|
||||||
{ ShortcutAction::QuickFix, RS_(L"QuickFixCommandKey") },
|
{ ShortcutAction::QuickFix, RS_(L"QuickFixCommandKey") },
|
||||||
|
{ ShortcutAction::OpenCWD, RS_(L"OpenCWDCommandKey") },
|
||||||
};
|
};
|
||||||
}();
|
}();
|
||||||
|
|
||||||
|
|||||||
@ -112,7 +112,8 @@
|
|||||||
ON_ALL_ACTIONS(ToggleBroadcastInput) \
|
ON_ALL_ACTIONS(ToggleBroadcastInput) \
|
||||||
ON_ALL_ACTIONS(OpenScratchpad) \
|
ON_ALL_ACTIONS(OpenScratchpad) \
|
||||||
ON_ALL_ACTIONS(OpenAbout) \
|
ON_ALL_ACTIONS(OpenAbout) \
|
||||||
ON_ALL_ACTIONS(QuickFix)
|
ON_ALL_ACTIONS(QuickFix) \
|
||||||
|
ON_ALL_ACTIONS(OpenCWD)
|
||||||
|
|
||||||
#define ALL_SHORTCUT_ACTIONS_WITH_ARGS \
|
#define ALL_SHORTCUT_ACTIONS_WITH_ARGS \
|
||||||
ON_ALL_ACTIONS_WITH_ARGS(AdjustFontSize) \
|
ON_ALL_ACTIONS_WITH_ARGS(AdjustFontSize) \
|
||||||
|
|||||||
@ -734,4 +734,7 @@
|
|||||||
<data name="QuickFixCommandKey" xml:space="preserve">
|
<data name="QuickFixCommandKey" xml:space="preserve">
|
||||||
<value>Open quick fix menu</value>
|
<value>Open quick fix menu</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="OpenCWDCommandKey" xml:space="preserve">
|
||||||
|
<value>Open current working directory</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
||||||
|
|||||||
@ -449,6 +449,7 @@
|
|||||||
{ "command": "experimental.openTasks", "id": "Terminal.OpenTasks" },
|
{ "command": "experimental.openTasks", "id": "Terminal.OpenTasks" },
|
||||||
{ "command": "quickFix", "id": "Terminal.QuickFix" },
|
{ "command": "quickFix", "id": "Terminal.QuickFix" },
|
||||||
{ "command": { "action": "showSuggestions", "source": "all"}, "id": "Terminal.Suggestions" },
|
{ "command": { "action": "showSuggestions", "source": "all"}, "id": "Terminal.Suggestions" },
|
||||||
|
{ "command": "openCWD", "id": "Terminal.OpenCWD" },
|
||||||
|
|
||||||
// Tab Management
|
// Tab Management
|
||||||
// "command": "closeTab" is unbound by default.
|
// "command": "closeTab" is unbound by default.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user