Skip to content

Commit c4f1665

Browse files
author
Sascha Goldhofer
committed
Fix broken goto command
1 parent 8cb0a6c commit c4f1665

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

command_goto_file.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,54 @@
11
import os
2-
import sublime
32
import re
3+
import sublime
44
import sublime_plugin
55
import FuzzyFilePath.expression as Context
66
import FuzzyFilePath.common.path as Path
77
from FuzzyFilePath.common.verbose import log
88
import FuzzyFilePath.common.selection as Selection
9+
import FuzzyFilePath.current_state as state
10+
11+
12+
ID = "GotoFile"
913

10-
ID = "goto file"
1114

1215
class FfpGotoFileCommand(sublime_plugin.TextCommand):
13-
""" go to file """
16+
""" open file under cursor """
1417
def run(self, edit):
1518
current_directory = os.path.dirname(self.view.file_name())
16-
1719
context = Context.get_context(self.view)
1820
if context.get("valid") is False:
1921
return log(ID, "abort, no valid path given:", context.get("needle"))
2022

2123
path = context.get("needle")
22-
project = state.get_project_directory()
24+
project_folder = state.get_project_directory()
2325

24-
if not (path and project):
25-
return log(ID, "path or project invalid", path, project)
26+
if not (path and project_folder):
27+
return log(ID, "path or project invalid", path, project_folder)
2628

2729
is_relative = Path.is_relative(path)
2830
if is_relative:
2931
path = Path.get_absolute_path(current_directory, path)
30-
path = re.sub(project.get_directory(), "", path)
32+
path = re.sub(project_folder, "", path)
3133

3234
path = re.sub("^[\\\\/\.]", "", path)
33-
files = project.find_file(path)
35+
files = state.find_file(path)
3436

3537
if len(files) == 0:
3638
return log(ID, "failed finding file", path)
3739

3840
if len(files) == 1:
39-
self.open_file(project.get_directory(), files[0])
41+
self.open_file(project_folder, files[0])
4042
else:
4143
# if javascript, search for index.js
4244
current_scope = self.view.scope_name(Selection.get_position(self.view))
4345
if re.search("\.js ", current_scope):
4446
for file in files:
4547
if "index.js" in file:
46-
return self.open_file(project.get_directory(), file)
48+
return self.open_file(project_folder, file)
4749

4850
self.files = files
49-
self.project_folder = project.get_directory()
51+
self.project_folder = project_folder
5052
self.view.show_popup_menu(files, self.select_file)
5153

5254
def select_file(self, index):

0 commit comments

Comments
 (0)