Skip to content

Commit 5c0d05e

Browse files
Merge pull request #8996 from matthiasblaesing/ideopen_windows
NetBeans terminal provides "ideopen" command to open a local path this fails on windows
2 parents 105a1e4 + 96bcca0 commit 5c0d05e

2 files changed

Lines changed: 13 additions & 14 deletions

File tree

ide/dlight.terminal/src/org/netbeans/modules/dlight/terminal/action/OpenInEditorActionProvider.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
*/
1919
package org.netbeans.modules.dlight.terminal.action;
2020

21-
import java.io.File;
2221
import java.net.MalformedURLException;
2322
import java.net.URL;
2423
import java.util.ArrayList;
@@ -28,13 +27,10 @@
2827
import org.netbeans.lib.terminalemulator.Term;
2928
import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment;
3029
import org.netbeans.modules.nativeexecution.api.ExecutionEnvironmentFactory;
31-
import org.netbeans.modules.nativeexecution.api.util.HostInfoUtils;
30+
import org.netbeans.modules.nativeexecution.api.util.WindowsSupport;
3231
import org.netbeans.modules.terminal.spi.ui.ExternalCommandActionProvider;
3332
import org.netbeans.modules.terminal.support.OpenInEditorAction;
34-
import org.openide.filesystems.FileObject;
35-
import org.openide.filesystems.FileUtil;
36-
import org.openide.filesystems.URLMapper;
37-
import org.openide.util.Exceptions;
33+
import org.openide.util.BaseUtilities;
3834
import org.openide.util.Lookup;
3935
import org.openide.util.lookup.ServiceProvider;
4036

@@ -83,12 +79,14 @@ public void handle(String command, Lookup lookup) {
8379

8480
Object key = lookup.lookup(Term.class).getClientProperty(Term.ExternalCommandsConstants.EXECUTION_ENV_PROPERTY_KEY);
8581
URL url = null;
82+
boolean remoteShell = false;
8683
try {
8784

8885
if (key instanceof String) {
8986
ExecutionEnvironment env = ExecutionEnvironmentFactory.fromUniqueID((String) key);
9087
if (env.isRemote()) {
9188
url = new URL("rfs://" + key + filePath); //NOI18N
89+
remoteShell = true;
9290
}
9391

9492
}
@@ -99,6 +97,12 @@ public void handle(String command, Lookup lookup) {
9997
if (url != null) {
10098
OpenInEditorAction.post(url, lineNumber);
10199
} else {
100+
if (!remoteShell && BaseUtilities.isWindows()) {
101+
// NetBeans only supports shells running via cygwin/msys
102+
// the paths then need to be converted to basic windows
103+
// paths
104+
filePath = WindowsSupport.getInstance().convertToWindowsPath(filePath);
105+
}
102106
OpenInEditorAction.post(filePath, lineNumber);
103107
}
104108
}

ide/terminal.nb/src/org/netbeans/modules/terminal/support/OpenInEditorAction.java

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@
2626
import org.openide.cookies.EditorCookie;
2727
import org.openide.cookies.LineCookie;
2828
import org.openide.filesystems.FileObject;
29-
import org.openide.filesystems.FileUtil;
3029
import org.openide.filesystems.URLMapper;
3130
import org.openide.loaders.DataObject;
3231
import org.openide.text.Line;
3332
import org.openide.util.Exceptions;
3433
import org.openide.util.RequestProcessor;
34+
import org.openide.util.Utilities;
3535

3636
/**
3737
*
@@ -52,7 +52,7 @@ public static void post(URL url, int lineNumber) {
5252

5353
public static void post(String filePath, int lineNumber) {
5454
try {
55-
RP.post(new OpenInEditorAction(new URL("file://" + filePath), lineNumber)); //NOI18N
55+
RP.post(new OpenInEditorAction(Utilities.toURI(new File(filePath)).toURL(), lineNumber)); //NOI18N
5656
} catch (MalformedURLException ex) {
5757
Exceptions.printStackTrace(ex);
5858
}
@@ -84,12 +84,7 @@ private void doWork() {
8484
return;
8585
}
8686
try {
87-
FileObject fo;
88-
if (url.getProtocol().equals("file")) { //NOI18N
89-
fo = FileUtil.toFileObject(new File(url.getPath()));
90-
} else {
91-
fo = URLMapper.findFileObject(url); //NOI18N
92-
}
87+
FileObject fo = URLMapper.findFileObject(url); //NOI18N
9388
DataObject dobj = DataObject.find(fo);
9489
EditorCookie ed = dobj.getLookup().lookup(EditorCookie.class);
9590
if (ed != null && fo == dobj.getPrimaryFile()) {

0 commit comments

Comments
 (0)