[PR #14048] [MERGED] OpenHere: Replace explorer window lookup code w/ site lookup #29908

Open
opened 2026-01-31 09:37:33 +00:00 by claunia · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/14048
Author: @DHowett
Created: 9/20/2022
Status: Merged
Merged: 9/21/2022
Merged by: @DHowett

Base: mainHead: dev/duhowett/shellext-site-chain


📝 Commits (2)

  • d8307d0 OpenHere: Replace the fxplorer Window lookup code with site lookup
  • d5589af Switch to wil::com_ptr!

📊 Changes

2 files changed (+57 additions, -125 deletions)

View changed files

📝 src/cascadia/ShellExtension/OpenTerminalHere.cpp (+48 -121)
📝 src/cascadia/ShellExtension/OpenTerminalHere.h (+9 -4)

📄 Description

When we first introduced the shell extension, it didn't work properly
for some folders (such as the Desktop, or perhaps any "background"
click) due to a bug in Windows. We worked around that bug with the help
of an awesome community member, who contributed code that would pull up
the topmost Explorer window and query its location.

That Windows bug was eventually fixed, but we still had trouble with
items appearing correctly. On Windows 11, the Open in Terminal menu item
appears and disappears at random when you right-click the desktop, but
it always appears when you right-click a folder. It sometimes appears
for Quick Access, even though it shouldn't.

We tried to fix that in #13206, but the fix caused more issues than it
solved. We reverted it for 1.15 and 1.16.

At the end of the day, it turns out that getting the path from the
toplevel explorer window is fragile. Fortunately, the shell does offer
us a way to get that information: the site chain.

This pull request replaces GetPathFromExplorer() with an implementation
of IObjectWithSite, which allows us to use the site chain to look up
from whence a context menu request was initiated. It also makes item
lookup generally more robust.

  • Tested on Windows 11
    • Desktop
    • Folder Background
    • Folder Selected
    • Quick Access (does not appear)
    • This PC (does not appear)
  • Tested on Windows 10
    • Desktop
    • Folder Background
    • Folder Selected
    • Quick Access (does not appear)
    • This PC (does not appear)

References #13206
References #13523
Closes #12578

Co-authored-by: John Lueders johnlue@microsoft.com


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/microsoft/terminal/pull/14048 **Author:** [@DHowett](https://github.com/DHowett) **Created:** 9/20/2022 **Status:** ✅ Merged **Merged:** 9/21/2022 **Merged by:** [@DHowett](https://github.com/DHowett) **Base:** `main` ← **Head:** `dev/duhowett/shellext-site-chain` --- ### 📝 Commits (2) - [`d8307d0`](https://github.com/microsoft/terminal/commit/d8307d0f7258f35919abebf47d6c33a61e47dce4) OpenHere: Replace the fxplorer Window lookup code with site lookup - [`d5589af`](https://github.com/microsoft/terminal/commit/d5589af04696fc333928ddc59c27e86df4ff6603) Switch to wil::com_ptr! ### 📊 Changes **2 files changed** (+57 additions, -125 deletions) <details> <summary>View changed files</summary> 📝 `src/cascadia/ShellExtension/OpenTerminalHere.cpp` (+48 -121) 📝 `src/cascadia/ShellExtension/OpenTerminalHere.h` (+9 -4) </details> ### 📄 Description When we first introduced the shell extension, it didn't work properly for some folders (such as the Desktop, or perhaps any "background" click) due to a bug in Windows. We worked around that bug with the help of an awesome community member, who contributed code that would pull up the topmost Explorer window and query its location. That Windows bug was eventually fixed, but we still had trouble with items appearing correctly. On Windows 11, the Open in Terminal menu item appears and disappears at random when you right-click the desktop, but it always appears when you right-click a folder. It sometimes appears for Quick Access, even though it shouldn't. We tried to fix that in #13206, but the fix caused more issues than it solved. We reverted it for 1.15 and 1.16. At the end of the day, it turns out that getting the path from the toplevel explorer window is fragile. Fortunately, the shell does offer us a way to get that information: the site chain. This pull request replaces GetPathFromExplorer() with an implementation of `IObjectWithSite`, which allows us to use the site chain to look up from whence a context menu request was initiated. It also makes item lookup generally more robust. * ✅ Tested on Windows 11 * ✅ Desktop * ✅ Folder Background * ✅ Folder Selected * ✅ Quick Access (does not appear) * ✅ This PC (does not appear) * ✅ Tested on Windows 10 * ✅ Desktop * ✅ Folder Background * ✅ Folder Selected * ✅ Quick Access (does not appear) * ✅ This PC (does not appear) References #13206 References #13523 Closes #12578 Co-authored-by: John Lueders <johnlue@microsoft.com> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-31 09:37:33 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#29908