Skip to content

Commit f392450

Browse files
egmontkobmattrose
authored andcommitted
Tolerate invalid OSC 7 values
When opening a new terminal, if the old terminal's working directory can't be extracted from OSC 7 (e.g. due to an invalid hostname) then fall back to the old method, rather than failing. Fixes #966
1 parent f28c1d3 commit f392450

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

terminatorlib/terminal.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -256,12 +256,14 @@ def get_cwd(self):
256256
"""Return our cwd"""
257257
vte_cwd = self.vte.get_current_directory_uri()
258258
if vte_cwd:
259-
# OSC7 pwd gives an answer
260-
return(GLib.filename_from_uri(vte_cwd)[0])
261-
else:
262-
# Fall back to old gtk2 method
263-
dbg('calling get_pid_cwd')
264-
return(get_pid_cwd(self.pid))
259+
# OSC7 pwd almost always gives an answer
260+
try:
261+
return(GLib.filename_from_uri(vte_cwd)[0])
262+
except:
263+
pass
264+
# Fall back to old gtk2 method
265+
dbg('calling get_pid_cwd')
266+
return(get_pid_cwd(self.pid))
265267

266268
def close(self):
267269
"""Close ourselves"""

0 commit comments

Comments
 (0)