Browse Source

fix: folder open not working in devtools (#15387)

Shelley Vohr 6 years ago
parent
commit
d21d83cfc8
2 changed files with 11 additions and 1 deletions
  1. 2 1
      atom/browser/ui/inspectable_web_contents_impl.cc
  2. 9 0
      lib/renderer/inspector.js

+ 2 - 1
atom/browser/ui/inspectable_web_contents_impl.cc

@@ -512,8 +512,9 @@ void InspectableWebContentsImpl::ShowItemInFolder(
     const std::string& file_system_path) {
   if (file_system_path.empty())
     return;
+
   base::FilePath path = base::FilePath::FromUTF8Unsafe(file_system_path);
-  platform_util::ShowItemInFolder(path);
+  platform_util::OpenItem(path);
 }
 
 void InspectableWebContentsImpl::SaveToFile(const std::string& url,

+ 9 - 0
lib/renderer/inspector.js

@@ -4,10 +4,19 @@ window.onload = function () {
   // Use menu API to show context menu.
   window.InspectorFrontendHost.showContextMenuAtPoint = createMenu
 
+  // correct for Chromium returning undefined for filesystem
+  window.Persistence.FileSystemWorkspaceBinding.completeURL = completeURL
+
   // Use dialog API to override file chooser dialog.
   window.UI.createFileSelectorElement = createFileSelectorElement
 }
 
+// Extra / is needed as a result of MacOS requiring absolute paths
+function completeURL (project, path) {
+  project = 'file:///'
+  return `${project}${path}`
+}
+
 window.confirm = function (message, title) {
   const { dialog } = require('electron').remote
   if (title == null) {