|
1 | | -from gi.repository import Nautilus, GObject, GLib |
2 | | -import os |
| 1 | +import json |
3 | 2 | import logging |
4 | | -from urllib.parse import unquote |
| 3 | +import os |
5 | 4 | from subprocess import call |
6 | | -import json |
| 5 | +from urllib.parse import unquote |
| 6 | + |
| 7 | +from gi.repository import GLib, GObject, Nautilus |
7 | 8 |
|
8 | 9 | # Configure logging |
9 | 10 | logging.basicConfig( |
@@ -92,25 +93,28 @@ def _open_workspace(self, menu, workspace_path): |
92 | 93 | self.launch_vscode(menu, [workspace_path]) |
93 | 94 |
|
94 | 95 | def _get_name(self, workspace): |
| 96 | + # Handle file:// paths |
95 | 97 | if workspace.startswith("file://"): |
96 | | - return workspace.replace("file://", "").replace(GLib.get_home_dir(), "~") |
97 | | - |
98 | | - if workspace.startswith("vscode-remote://"): |
99 | | - workspace_name = workspace.replace("vscode-remote://", "") |
100 | | - if workspace_name.startswith("ssh-remote+"): |
101 | | - workspace_name = workspace_name.replace("ssh-remote+", "") |
102 | | - if "/" not in workspace_name: |
103 | | - return None |
104 | | - wns = workspace_name.split("/") |
105 | | - if len(wns) < 2: |
106 | | - return None |
107 | | - ssh_host = wns[0] |
108 | | - workspace_name = workspace_name.replace(ssh_host, "") |
109 | | - if len(wns) >= 4: |
110 | | - workspace_name = "~/" + "/".join(wns[3:]) |
111 | | - return f"[SHH: {ssh_host}] {workspace_name}" |
112 | | - |
113 | | - return workspace |
| 98 | + path = workspace.replace("file://", "") |
| 99 | + return path.replace(GLib.get_home_dir(), "~") |
| 100 | + |
| 101 | + # Early return for non-vscode-remote paths |
| 102 | + if not workspace.startswith("vscode-remote://ssh-remote+"): |
| 103 | + return workspace |
| 104 | + |
| 105 | + # Process SSH remote workspace path |
| 106 | + parts = workspace[len("vscode-remote://ssh-remote+"):].split("/", 3) |
| 107 | + |
| 108 | + # Validate path structure |
| 109 | + if len(parts) < 2: |
| 110 | + return None |
| 111 | + ssh_host = parts[0] |
| 112 | + |
| 113 | + # Construct workspace path |
| 114 | + workspace_path = f"~/{parts[3]}" if len( |
| 115 | + parts) >= 4 else "/".join(parts[1:]) |
| 116 | + |
| 117 | + return f"[SSH: {ssh_host}] {workspace_path}" |
114 | 118 |
|
115 | 119 | def get_background_items(self, window): |
116 | 120 | recent_workspaces = self._get_recent_workspaces() |
|
0 commit comments