From d21d83cfc84f80a44c33cd1830d57b0427363e32 Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Thu, 25 Oct 2018 08:36:48 -0700 Subject: [PATCH] fix: folder open not working in devtools (#15387) --- atom/browser/ui/inspectable_web_contents_impl.cc | 3 ++- lib/renderer/inspector.js | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/atom/browser/ui/inspectable_web_contents_impl.cc b/atom/browser/ui/inspectable_web_contents_impl.cc index aa3e0d9cb498..b1cc4563b3d3 100644 --- a/atom/browser/ui/inspectable_web_contents_impl.cc +++ b/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, diff --git a/lib/renderer/inspector.js b/lib/renderer/inspector.js index 59c5164f0ba6..b358fa65cb1e 100644 --- a/lib/renderer/inspector.js +++ b/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) {