Fix view file in Edge failure issue if name contains spaces

Added Edge to the same case as the other browsers, which substitutes spaces for %20, and opens the files as expected and add legacy edge as a backup in case the new edge isn't found.

Fix #9313, close #9677
This commit is contained in:
jofon 2021-03-20 17:02:01 +00:00 committed by Don HO
parent 874f0d0140
commit bdae2aef92

View File

@ -1989,6 +1989,7 @@ void Notepad_plus::command(int id)
case IDM_VIEW_IN_FIREFOX: case IDM_VIEW_IN_FIREFOX:
case IDM_VIEW_IN_CHROME: case IDM_VIEW_IN_CHROME:
case IDM_VIEW_IN_EDGE:
case IDM_VIEW_IN_IE: case IDM_VIEW_IN_IE:
{ {
auto currentBuf = _pEditView->getCurrentBuffer(); auto currentBuf = _pEditView->getCurrentBuffer();
@ -2004,6 +2005,10 @@ void Notepad_plus::command(int id)
{ {
appName = TEXT("chrome.exe"); appName = TEXT("chrome.exe");
} }
else if (id == IDM_VIEW_IN_EDGE)
{
appName = TEXT("msedge.exe");
}
else // if (id == IDM_VIEW_IN_IE) else // if (id == IDM_VIEW_IN_IE)
{ {
appName = TEXT("IEXPLORE.EXE"); appName = TEXT("IEXPLORE.EXE");
@ -2027,7 +2032,18 @@ void Notepad_plus::command(int id)
{ {
::ShellExecute(NULL, TEXT("open"), valData, fullCurrentPath.c_str(), NULL, SW_SHOWNORMAL); ::ShellExecute(NULL, TEXT("open"), valData, fullCurrentPath.c_str(), NULL, SW_SHOWNORMAL);
} }
else else if (id == IDM_VIEW_IN_EDGE)
{
// Try the Legacy version
// Don't put the quots for Edge, otherwise it doesn't work
//fullCurrentPath = TEXT("\"");
generic_string fullCurrentPath = currentBuf->getFullPathName();
//fullCurrentPath += TEXT("\"");
::ShellExecute(NULL, TEXT("open"), TEXT("shell:Appsfolder\\Microsoft.MicrosoftEdge_8wekyb3d8bbwe!MicrosoftEdge"), fullCurrentPath.c_str(), NULL, SW_SHOW);
}
else
{ {
_nativeLangSpeaker.messageBox("ViewInBrowser", _nativeLangSpeaker.messageBox("ViewInBrowser",
_pPublicInterface->getHSelf(), _pPublicInterface->getHSelf(),
@ -2039,21 +2055,6 @@ void Notepad_plus::command(int id)
} }
} }
break; break;
case IDM_VIEW_IN_EDGE:
{
auto currentBuf = _pEditView->getCurrentBuffer();
if (!currentBuf->isUntitled())
{
// Don't put the quots for Edge, otherwise it doesn't work
//fullCurrentPath = TEXT("\"");
generic_string fullCurrentPath = currentBuf->getFullPathName();
//fullCurrentPath += TEXT("\"");
ShellExecute(NULL, TEXT("open"), TEXT("shell:Appsfolder\\Microsoft.MicrosoftEdge_8wekyb3d8bbwe!MicrosoftEdge"), fullCurrentPath.c_str(), NULL, SW_SHOW);
}
}
break;
case IDM_VIEW_TAB_SPACE: case IDM_VIEW_TAB_SPACE:
{ {