mirror of
https://github.com/microsoft/terminal.git
synced 2025-12-10 00:48:23 -06:00
Allow wt.json to refer to local media (resolved with the settings' default resolver)
This commit is contained in:
parent
814f78ed2c
commit
6b2fe92e53
10
.wt.json
10
.wt.json
@ -26,8 +26,14 @@
|
||||
},
|
||||
{
|
||||
"input": "runut /name:**\u001b[D",
|
||||
"name": "Run a test",
|
||||
"icon": "",
|
||||
"name": "This one uses the icon from terminal",
|
||||
"icon": "res/terminal.ico",
|
||||
"description": "Enter the name of a test to run"
|
||||
},
|
||||
{
|
||||
"input": "runut /name:**\u001b[D",
|
||||
"name": "This one uses the icon from conhost",
|
||||
"icon": "res/console.ico",
|
||||
"description": "Enter the name of a test to run"
|
||||
}
|
||||
]
|
||||
|
||||
@ -15,6 +15,8 @@ using namespace winrt::Microsoft::Terminal::Settings::Model;
|
||||
using namespace winrt::Microsoft::Terminal::Control;
|
||||
using namespace winrt::Windows::Foundation::Collections;
|
||||
|
||||
extern void _resolveSingleMediaResourceInner(OriginTag origin, std::wstring_view basePath, const IMediaResource& resource);
|
||||
|
||||
namespace winrt::Microsoft::Terminal::Settings::Model::implementation
|
||||
{
|
||||
static InternalActionID Hash(const Model::ActionAndArgs& actionAndArgs)
|
||||
@ -1257,6 +1259,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
|
||||
std::unordered_map<hstring, Model::Command> ActionMap::_loadLocalSnippets(const std::filesystem::path& currentWorkingDirectory)
|
||||
{
|
||||
// This returns an empty string if we fail to load the file.
|
||||
const winrt::hstring basePath{ currentWorkingDirectory.native() };
|
||||
std::filesystem::path localSnippetsPath = currentWorkingDirectory / std::filesystem::path{ ".wt.json" };
|
||||
const auto data = til::io::read_file_as_utf8_string_if_exists(localSnippetsPath);
|
||||
if (data.empty())
|
||||
@ -1283,6 +1286,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
|
||||
for (const auto& json : actions)
|
||||
{
|
||||
const auto snippet = Command::FromSnippetJson(json);
|
||||
snippet->ResolveMediaResourcesWithBasePath(basePath, MediaResourceResolver{ _resolveSingleMediaResourceInner });
|
||||
result.insert_or_assign(snippet->Name(), *snippet);
|
||||
}
|
||||
}
|
||||
|
||||
@ -490,7 +490,7 @@ void CascadiaSettings::_validateAllSchemesExist()
|
||||
|
||||
extern bool TestHook_CascadiaSettings_ResolveSingleMediaResource(Model::OriginTag origin, std::wstring_view basePath, const Model::IMediaResource& resource);
|
||||
|
||||
static void _resolveSingleMediaResourceInner(Model::OriginTag origin, std::wstring_view basePath, const Model::IMediaResource& resource)
|
||||
void _resolveSingleMediaResourceInner(Model::OriginTag origin, std::wstring_view basePath, const Model::IMediaResource& resource)
|
||||
{
|
||||
if (TestHook_CascadiaSettings_ResolveSingleMediaResource(origin, basePath, resource))
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user