Skip to content

Commit 2208c64

Browse files
author
Sascha Goldhofer
committed
Add check real filepath if not found in cache
1 parent 7f46d62 commit 2208c64

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

command_goto_file.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,19 @@ def run(self, edit):
3131
path = Path.get_absolute_path(current_directory, path)
3232
path = re.sub(project_folder, "", path)
3333

34+
3435
path = re.sub("^[\\\\/\.]", "", path)
36+
realpath = path
3537
# cleanup string, in case there are special characters for a path
3638
# e.g. webpack uses ~, which is not part of path
3739
path = re.sub("[^A-Za-z0-9 \-_\\\\/.%?#]*", "", path)
3840
files = state.find_file(path)
3941

4042
if len(files) == 0:
41-
return log(ID, "failed finding file", path)
43+
# it may be an uncached file, try to open it by using the real path
44+
if self.filepath_exists(os.path.join(project_folder, realpath)):
45+
return self.open_file(project_folder, realpath)
46+
return log(ID, "failed finding file", path, "it is not within the cache and not a realpath")
4247

4348
if len(files) == 1:
4449
self.open_file(project_folder, files[0])
@@ -54,6 +59,9 @@ def run(self, edit):
5459
self.project_folder = project_folder
5560
self.view.show_popup_menu(files, self.select_file)
5661

62+
def filepath_exists(self, filepath):
63+
return os.path.isfile(filepath)
64+
5765
def select_file(self, index):
5866
self.open_file(self.project_folder, self.files[index])
5967
self.files = None

0 commit comments

Comments
 (0)