Skip to content

Commit 9d7fb1c

Browse files
authored
fix opening span links on windows (#176)
1 parent 5a75fa8 commit 9d7fb1c

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

src/main/java/org/digma/intellij/plugin/service/EditorService.java

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import com.intellij.openapi.ui.Messages;
1111
import com.intellij.openapi.vcs.VcsException;
1212
import com.intellij.openapi.vcs.vfs.ContentRevisionVirtualFile;
13-
import com.intellij.openapi.vfs.VfsUtil;
1413
import com.intellij.openapi.vfs.VirtualFile;
1514
import com.intellij.openapi.vfs.VirtualFileManager;
1615
import com.intellij.testFramework.BinaryLightVirtualFile;
@@ -21,8 +20,6 @@
2120
import org.jetbrains.annotations.NotNull;
2221
import org.jetbrains.annotations.Nullable;
2322

24-
import java.net.MalformedURLException;
25-
import java.net.URL;
2623
import java.util.Arrays;
2724

2825
public class EditorService implements Disposable {
@@ -174,18 +171,13 @@ private boolean showIfAlreadyOpen(String name, int lineNumber) {
174171

175172
public void openSpanWorkspaceFileInEditor(@NotNull String workspaceUri, int offset) {
176173

177-
try {
178-
var fileToOpen = VfsUtil.findFileByURL(new URL(workspaceUri));
179-
if (fileToOpen == null) {
180-
NotificationUtil.notifyError(project, "Could not find file " + workspaceUri);
181-
return;
182-
}
183-
OpenFileDescriptor openFileDescriptor = new OpenFileDescriptor(project, fileToOpen, Math.max(offset, 0));
184-
FileEditorManager.getInstance(project).openTextEditor(openFileDescriptor, true);
185-
} catch (MalformedURLException e) {
186-
Log.log(LOGGER::warn, "Could not open file " + workspaceUri + ", Exception" + e.getMessage());
187-
NotificationUtil.notifyError(project, "Could not open file " + workspaceUri + ", Exception:" + e.getMessage());
174+
var fileToOpen = VirtualFileManager.getInstance().findFileByUrl(workspaceUri);
175+
if (fileToOpen == null) {
176+
NotificationUtil.notifyError(project, "Could not find file " + workspaceUri);
177+
return;
188178
}
179+
OpenFileDescriptor openFileDescriptor = new OpenFileDescriptor(project, fileToOpen, Math.max(offset, 0));
180+
FileEditorManager.getInstance(project).openTextEditor(openFileDescriptor, true);
189181
}
190182

191183

0 commit comments

Comments
 (0)