Skip to content

Commit

Permalink
pr nits, spellcheck
Browse files Browse the repository at this point in the history
  • Loading branch information
zadjii-msft committed May 27, 2020
1 parent 5b75378 commit 753fcb3
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 44 deletions.
2 changes: 1 addition & 1 deletion .github/actions/spell-check/patterns/patterns.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
https://(?:(?:[-a-zA-Z0-9?&=]*\.|)microsoft\.com)/[-a-zA-Z0-9?&=_\/.]*
https://(?:(?:[-a-zA-Z0-9?&=]*\.|)microsoft\.com)/[-a-zA-Z0-9?&=_#\/.]*
https://aka\.ms/[-a-zA-Z0-9?&=\/_]*
https://www.w3.org/[-a-zA-Z0-9?&=\/_#]*
https://(?:(?:www\.|)youtube\.com|youtu.be)/[-a-zA-Z0-9?&=]*
Expand Down
2 changes: 2 additions & 0 deletions .github/actions/spell-check/whitelist/web.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ www
ecma
rapidtables
WCAG
winui
appshellintegration
2 changes: 1 addition & 1 deletion .github/actions/spell-check/whitelist/whitelist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2145,7 +2145,7 @@ SHIFTJIS
Shl
shlguid
shlobj
shlobjidl
shobjidl
shlwapi
SHORTPATH
SHOWCURSOR
Expand Down
82 changes: 43 additions & 39 deletions src/cascadia/ShellExtension/OpenTerminalHere.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,53 +47,57 @@ bool IsDevBuild()
// for this instance of the shell extension. If we're running the dev build,
// it should be a `wtd.exe`, but if we're preview or release, we want to make
// sure to get the correct `wt.exe` that corresponds to _us_.
// - If we're unpackaged, this needs to get us `windowsterminal.exe`, because
// - If we're unpackaged, this needs to get us `WindowsTerminal.exe`, because
// the `wt*exe` alias won't have been installed for this install.
// Arguments:
// - <none>
// Return Value:
// - the full path to the exe, one of `wt.exe`, `wtd.exe`, or `windowsterminal.exe`.
// - the full path to the exe, one of `wt.exe`, `wtd.exe`, or `WindowsTerminal.exe`.
std::wstring _getExePath()
{
// First, check a packaged location for the exe. If we've got a package
// family name, that means we're one of the packaged Dev build, packaged
// Release build, or packaged Preview build.
//
// If we're the preview or release build, there's no way of knowing if the
// `wt.exe` on the %PATH% is us or not. Fortunately, _our_ execution alias
// is located in "%LOCALAPPDATA%\Microsoft\WindowsApps\<our package family
// name>", _always_, so we can use that to look up the exe easier.
try
{
const auto package{ winrt::Windows::ApplicationModel::Package::Current() };
const auto id = package.Id();
const std::wstring pfn{ id.FamilyName() };
if (!pfn.empty())
// use C++11 magic statics to make sure we only do this once.
static const std::wstring exepath = []() -> std::wstring {
// First, check a packaged location for the exe. If we've got a package
// family name, that means we're one of the packaged Dev build, packaged
// Release build, or packaged Preview build.
//
// If we're the preview or release build, there's no way of knowing if the
// `wt.exe` on the %PATH% is us or not. Fortunately, _our_ execution alias
// is located in "%LOCALAPPDATA%\Microsoft\WindowsApps\<our package family
// name>", _always_, so we can use that to look up the exe easier.
try
{
const std::filesystem::path windowsAppsPath{ wil::ExpandEnvironmentStringsW<std::wstring>(L"%LOCALAPPDATA%\\Microsoft\\WindowsApps\\") };
const std::filesystem::path wtPath = windowsAppsPath / pfn / (IsDevBuild() ? L"wtd.exe" : L"wt.exe");
return wtPath;
const auto package{ winrt::Windows::ApplicationModel::Package::Current() };
const auto id = package.Id();
const std::wstring pfn{ id.FamilyName() };
if (!pfn.empty())
{
const std::filesystem::path windowsAppsPath{ wil::ExpandEnvironmentStringsW<std::wstring>(L"%LOCALAPPDATA%\\Microsoft\\WindowsApps\\") };
const std::filesystem::path wtPath = windowsAppsPath / pfn / (IsDevBuild() ? L"wtd.exe" : L"wt.exe");
return wtPath;
}
}
}
CATCH_LOG();
CATCH_LOG();

// If we're here, then we couldn't resolve our exe from the package. This
// means we're running unpackaged. We should just use the
// WindowsTerminal.exe that's sitting in the directory next to us.
try
{
HMODULE hModule = GetModuleHandle(nullptr);
THROW_LAST_ERROR_IF(hModule == nullptr);
std::wstring dllPathString;
THROW_IF_FAILED(wil::GetModuleFileNameW(hModule, dllPathString));
const std::filesystem::path dllPath{ dllPathString };
const std::filesystem::path rootDir = dllPath.parent_path();
std::filesystem::path wtPath = rootDir / "WindowsTerminal.exe";
return wtPath;
}
CATCH_LOG();
// If we're here, then we couldn't resolve our exe from the package. This
// means we're running unpackaged. We should just use the
// WindowsTerminal.exe that's sitting in the directory next to us.
try
{
HMODULE hModule = GetModuleHandle(nullptr);
THROW_LAST_ERROR_IF(hModule == nullptr);
std::wstring dllPathString;
THROW_IF_FAILED(wil::GetModuleFileNameW(hModule, dllPathString));
const std::filesystem::path dllPath{ dllPathString };
const std::filesystem::path rootDir = dllPath.parent_path();
std::filesystem::path wtPath = rootDir / "WindowsTerminal.exe";
return wtPath;
}
CATCH_LOG();

return L"wt.exe";
return L"wt.exe";
}();
return exepath;
}

// Method Description:
Expand Down Expand Up @@ -142,10 +146,10 @@ HRESULT OpenTerminalHere::Invoke(IShellItemArray* psiItemArray,
}

HRESULT OpenTerminalHere::GetToolTip(IShellItemArray* /*psiItemArray*/,
LPWSTR* ppszInfotip)
LPWSTR* ppszInfoTip)
{
// tooltip provided here, in this case none is provided
*ppszInfotip = nullptr;
*ppszInfoTip = nullptr;
return E_NOTIMPL;
}

Expand Down
6 changes: 3 additions & 3 deletions src/cascadia/ShellExtension/OpenTerminalHere.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ Author(s):
using namespace Microsoft::WRL;

struct __declspec(uuid("9f156763-7844-4dc4-bbb1-901f640f5155"))
OpenTerminalHere : public RuntimeClass<RuntimeClassFlags<ClassicCom>, IExplorerCommand>
OpenTerminalHere : public RuntimeClass<RuntimeClassFlags<ClassicCom | InhibitFtmBase>, IExplorerCommand>
{
#pragma region IExplorerCommand
HRESULT Invoke(IShellItemArray* psiItemArray,
IBindCtx* pbc);
IBindCtx* pBindContext);
HRESULT GetToolTip(IShellItemArray* psiItemArray,
LPWSTR* ppszInfotip);
LPWSTR* ppszInfoTip);
HRESULT GetTitle(IShellItemArray* psiItemArray,
LPWSTR* ppszName);
HRESULT GetState(IShellItemArray* psiItemArray,
Expand Down

1 comment on commit 753fcb3

@github-actions
Copy link

Choose a reason for hiding this comment

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

New misspellings found, please review:

  • bbb
  • exepath
To accept these changes, run the following commands
remove_obsolete_words=$(mktemp)
echo '#!/usr/bin/perl -ni
my $re=join "|", qw('"
AAD
abcd
abe
abec
acb
afae
afceeeaa
atg
baac
bbd
bca
bcb
bcc
bda
bfb
bitfield
BKMK
caa
carlos
cbb
consoleaccessibility
dcf
ddb
dfa
eba
ebce
EBFB
ECFB
eeb
eee
Emoji
Emojis
fbb
fbd
FBE
fcc
fd
fdb
fdd
ffc
HREF
memcpying
OUTPATHROOT
shobjidl
storageitems
textblock
usr
vpack
zamora
"');
next if /^($re)(?:$| .*)/;
print;' > $remove_obsolete_words
chmod +x $remove_obsolete_words
for file in .github/actions/spell-check/whitelist/alphabet.txt .github/actions/spell-check/whitelist/web.txt .github/actions/spell-check/whitelist/whitelist.txt; do $remove_obsolete_words $file; done
rm $remove_obsolete_words
(
echo "
ABE
bbb
EEB
exepath
FDD
Shobjidl
"
) | sort -u -f | perl -ne 'next unless /./; print' > new_whitelist.txt && mv new_whitelist.txt '.github/actions/spell-check/whitelist/753fcb3a84cfe90d83aa9d538d05d3848b7d4eb4.txt'
✏️ Contributor please read this
  • If the items listed above are names, please add them to .github/actions/spell-check/dictionary/names.txt.
  • If they're APIs, you can add them to a file in .github/actions/spell-check/dictionary/.
  • If they're just things you're using, please add them to an appropriate file in .github/actions/spell-check/whitelist/.
  • If you need to use a specific token in one place and it shouldn't generally be used, you can
    add an item in an appropriate file in .github/actions/spell-check/patterns/.

See the README.md in each directory for more information.

⚠️ Reviewers

At present, the action that triggered this message will not show its ❌ in this PR unless the branch is within this repository.
Thus, you should make sure that this comment has been addressed before encouraging the merge bot to merge this PR.

Please sign in to comment.