Skip to content

Commit 6973a94

Browse files
committedFeb 18, 2016
gui/explorer: fix 'parent folder' on Windows
1 parent 155c2ec commit 6973a94

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed
 

‎artiq/gui/explorer.py

+17-15
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import asyncio
22
import logging
3+
import re
34
from functools import partial
45

56
from PyQt5 import QtCore, QtWidgets
@@ -77,23 +78,24 @@ def accept(self):
7778
if selected:
7879
selected = selected[0].text()
7980
if selected == "..":
80-
if (not self.explorer.current_directory
81-
or self.explorer.current_directory[-1] not in "\\/"):
81+
if not self.explorer.current_directory:
8282
return
83-
idx = None
84-
for sep in "\\/":
85-
try:
86-
idx = self.explorer.current_directory[:-1].rindex(sep)
87-
except ValueError:
88-
pass
89-
else:
90-
break
91-
if idx is None:
92-
return
93-
self.explorer.current_directory = \
94-
self.explorer.current_directory[:idx+1]
95-
if self.explorer.current_directory == "/":
83+
if re.fullmatch("[a-zA-Z]:\\\\",
84+
self.explorer.current_directory):
9685
self.explorer.current_directory = ""
86+
else:
87+
idx = None
88+
for sep in "\\/":
89+
try:
90+
idx = self.explorer.current_directory[:-1].rindex(sep)
91+
except ValueError:
92+
pass
93+
else:
94+
break
95+
self.explorer.current_directory = \
96+
self.explorer.current_directory[:idx+1]
97+
if self.explorer.current_directory == "/":
98+
self.explorer.current_directory = ""
9799
asyncio.ensure_future(self.refresh_view())
98100
elif selected[-1] in "\\/":
99101
self.explorer.current_directory += selected

0 commit comments

Comments
 (0)
Please sign in to comment.