Repository: microsoft/terminal
File: src/cascadia/TerminalSettingsModel/ActionMap.cpp (C++)

Code before:

        // iterate over all the commands in all our actions...
        for (auto&& [name, command] : nameMap)
        {
            addCommand(command);
        }
        // ... and all the local commands passed in here
        for (const auto& command : localCommands)
        {
            addCommand(command);
        }

        return results;
    }

    // Update ActionMap's cache of actions for this directory. We'll look for a
    // .wt.json in this directory. If it exists, we'll read it, parse it's JSON,
    // then take all the sendInput actions in it and store them in our
    // _cwdLocalSnippetsCache
    winrt::Windows::Foundation::IAsyncAction ActionMap::_updateLocalSnippetCache(winrt::hstring currentWorkingDirectory)
    {
        // Don't do I/O on the main thread
        co_await winrt::resume_background();

        // This returns an empty string if we fail to load the file.
        auto localTasksFileContents = CascadiaSettings::ReadFile(currentWorkingDirectory + L"\\.wt.json");
        if (!localTasksFileContents.empty())
        {
            auto data = winrt::to_string(localTasksFileContents);
            std::string errs;
            static std::unique_ptr<Json::CharReader> reader{ Json::CharReaderBuilder::CharReaderBuilder().newCharReader() };
            Json::Value root;
            if (!reader->parse(data.data(), data.data() + data.size(), &root, &errs))
            {
                // In the real settings parser, we'd throw here:
                // throw winrt::hresult_error(WEB_E_INVALID_JSON_STRING, winrt::to_hstring(errs));
                //
                // That seems overly aggressive for something that we don't
                // really own. Instead, just bail out.
                co_return;
            }

            auto result = std::vector<Model::Command>();
            if (auto actions{ root[JsonKey("actions")] })
            {
                std::vector<SettingsLoadWarnings> warnings;
                for (const auto& json : actions)
                {
                    auto parsed = Command::FromJson(json, warnings, OriginTag::Generated);
                    // Skip over things that aren't snippets
                    if (parsed->ActionAndArgs().Action() != ShortcutAction::SendInput)

Review comment (suggestion):
```suggestion
        const auto localTasksFileContents = CascadiaSettings::ReadFile(currentWorkingDirectory + L"\\.wt.json");
```

Code after:
                }
            }
        };

        // iterate over all the commands in all our actions...
        for (auto&& [_, command] : nameMap)
        {
            addCommand(command);
        }
        // ... and all the local commands passed in here
        for (const auto& command : localCommands)
        {
            addCommand(command);
        }

        return results;
    }

    void ActionMap::AddSendInputAction(winrt::hstring name, winrt::hstring input, const Control::KeyChord keys)
    {
        auto newAction = winrt::make<ActionAndArgs>();
        newAction.Action(ShortcutAction::SendInput);
        auto sendInputArgs = winrt::make<SendInputArgs>(input);
        newAction.Args(sendInputArgs);
        auto cmd{ make_self<Command>() };
        if (!name.empty())
        {
            cmd->Name(name);
        }
        cmd->ActionAndArgs(newAction);
        cmd->GenerateID();
        AddAction(*cmd, keys);
    }

    // Update ActionMap's cache of actions for this directory. We'll look for a
    // .wt.json in this directory. If it exists, we'll read it, parse it's JSON,
    // then take all the sendInput actions in it and store them in our
    // _cwdLocalSnippetsCache
    std::vector<Model::Command> ActionMap::_updateLocalSnippetCache(winrt::hstring currentWorkingDirectory)
    {
        // This returns an empty string if we fail to load the file.
        std::filesystem::path localSnippetsPath{ std::wstring_view{ currentWorkingDirectory + L"\\.wt.json" } };
        const auto localTasksFileContents = til::io::read_file_as_utf8_string_if_exists(localSnippetsPath);
        if (!localTasksFileContents.has_value() || localTasksFileContents->empty())
        {
            return {};
        }

        const auto& data = *localTasksFileContents;
        Json::Value root;
        std::string errs;