Skip to content

Commit 7b5351c

Browse files
committed
Optimize goto function.
1 parent 1fc2052 commit 7b5351c

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

erl_autocompletion.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ def run(self, edit):
9797
else:
9898
row_id = 1
9999
cur_view_postion = {}
100+
all_cur_view_fun = []
100101
module = self.get_module_from_path(filepath)
101102
code = self.view.substr(sublime.Region(0, self.view.size()))
102103
for line in code.split('\n'):
@@ -106,11 +107,14 @@ def run(self, edit):
106107
param_str = funhead.group(2)
107108
param_list = self.format_param(param_str)
108109
key = (module, fun_name)
109-
format_fun_name = '{0}/{1}'.format(fun_name, len(param_list))
110+
param_len = len(param_list)
111+
format_fun_name = '{0}/{1}'.format(fun_name, param_len)
110112

111-
if key not in cur_view_postion:
112-
cur_view_postion[key] = []
113-
cur_view_postion[key].append((format_fun_name, filepath, row_id))
113+
if (key, param_len) not in all_cur_view_fun:
114+
if key not in cur_view_postion:
115+
cur_view_postion[key] = []
116+
cur_view_postion[key].append((format_fun_name, filepath, row_id))
117+
all_cur_view_fun.append((key, param_len))
114118
row_id += 1
115119

116120
self.__window_quick_panel_open_window(cur_view_postion[project_key])
@@ -128,6 +132,11 @@ def __window_quick_panel_open_window(self, options):
128132
self.point = self.view.sel()[0]
129133
self.options = options
130134

135+
if len(options) == 1:
136+
(_fun_name, path, row) = options[0]
137+
self.window.open_file('{}:{}:0'.format(path, row), sublime.ENCODED_POSITION)
138+
return
139+
131140
self.window.show_quick_panel(
132141
[self.__show_option(o) for o in options],
133142
self._jump_to_in_window,

sublime_erlang.sublime-settings

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// if escript not in the path, we need set escript path.
33
// "escript" : "D:\\erl8.3\\erts-8.3\\bin\\escript",
44

5-
"sublime_erlang_version" : "1.0.3",
5+
"sublime_erlang_version" : "1.0.4",
66

77
// "erlang_project_folder" : []
88
}

0 commit comments

Comments
 (0)