@@ -115,72 +115,89 @@ def on_query_completions(self, view, prefix, locations):
115
115
116
116
_res = self .completion (view , view .file_name ())
117
117
118
- if _res is None :
119
118
#explicitly no completion
119
+ if _res is None :
120
+ # print('[flow] completion res was none')
120
121
return ([], sublime .INHIBIT_WORD_COMPLETIONS | sublime .INHIBIT_EXPLICIT_COMPLETIONS )
121
122
else :
122
123
if (len (_res )):
123
124
return (_res , sublime .INHIBIT_WORD_COMPLETIONS | sublime .INHIBIT_EXPLICIT_COMPLETIONS )
125
+ # else:
126
+ # print('[flow] completion _res `{}`'.format(_res))
124
127
125
128
def completion (self , view , fname ):
126
129
127
130
if self .flow_file == "" or self .flow_file is None :
128
131
sublime .status_message ("No flow file, right click in a flow file! {}" .format (str (self .flow_file )))
132
+ # print('[flow] completion return [], no flow file')
129
133
return []
130
134
131
135
if not self .hxml_data :
132
136
sublime .status_message ("no info/hxml for flow file, caching..." )
133
137
self .refresh_info ()
134
138
135
- sel = view .sel ()[0 ]
136
- word = view .word (sel )
139
+ #ignore strings, comments, #if conditionals, for some reason the triggers won't work
140
+ ifsel = view .sel ()[0 ]
141
+ ifsel .a -= 2 ; ifsel .b -= 2
142
+ scsel = view .sel ()[0 ]
143
+ ifdef_score = view .score_selector (ifsel .begin (), "source - (keyword.control.directive.conditional.haxe)" )
144
+ scope_score = view .score_selector (scsel .begin (), "source - (comment, string.quoted, keyword.control.directive.conditional.haxe)" )
145
+ # print('[flow] ifdef score `{}`'.format(str(ifdef_score)))
146
+ # print('[flow] scope score `{}`'.format(str(scope_score)))
147
+
148
+ if scope_score <= 0 or ifdef_score <= 0 :
149
+ # print('[flow] ignore invalid scope for completion')
150
+ return None
137
151
138
- if len (word ) == 0 :
139
- return []
152
+ sel = view .sel ()[0 ]; sel .a -= 1
153
+ ch = view .substr (sel )
154
+ # print('[flow] completion ch `{}`'.format(ch))
155
+
156
+ if ch != "." and ch != "(" :
157
+ # print('[flow] ignore completion by non . or (')
158
+ return None
140
159
141
- ch = view .substr (word )[0 ]
142
160
code = view .substr (sublime .Region (0 , view .size ()))
143
- prior = code [0 :sel .begin ()].encode ('utf-8' )
161
+ prior = code [0 :view . sel ()[ 0 ] .begin ()].encode ('utf-8' )
144
162
offset = len (prior )
145
163
146
164
cwd = self .get_working_dir ()
147
165
filename = fname
148
166
149
- if ch == "." or ch == "(" :
150
-
151
- from sublime_haxe .haxe_completion import _completionist_
167
+ from sublime_haxe .haxe_completion import _completionist_
152
168
153
- self .completion_file = fname
154
- self .completion_view = view
155
- self .completion_data = None
169
+ self .completion_file = fname
170
+ self .completion_view = view
171
+ self .completion_data = None
156
172
157
- _hxml = self .hxml_data .splitlines ()
173
+ _hxml = self .hxml_data .splitlines ()
158
174
159
- self .completion_pending = True
175
+ self .completion_pending = True
160
176
161
- self .completion_start_time = time .time ()
177
+ self .completion_start_time = time .time ()
162
178
163
- self .save_file_for_completion (view , fname )
179
+ self .save_file_for_completion (view , fname )
164
180
165
- result = _completionist_ .complete (cwd , filename , offset , _hxml )
181
+ result = _completionist_ .complete (cwd , filename , offset , _hxml )
166
182
167
- self .restore_file_post_completion ()
183
+ self .restore_file_post_completion ()
168
184
169
- time_diff = time .time () - self .completion_start_time
170
- print ("[flow] completion took {}" .format (time_diff ))
171
- # print("[flow]\n{}".format(result))
185
+ time_diff = time .time () - self .completion_start_time
186
+ print ("[flow] completion took {}" .format (time_diff ))
187
+ # print("[flow]\n{}".format(result))
172
188
173
- _err = haxe_has_error (result )
174
- if _err :
175
- return self .show_errors (view , _err )
189
+ if not result :
190
+ return None
176
191
177
- _args = haxe_has_args (result )
178
- if _args :
179
- return self .show_args (view , _args )
192
+ _err = haxe_has_error (result )
193
+ if _err :
194
+ return self .show_errors (view , _err )
180
195
181
- return haxe_completion_list (result )
196
+ _args = haxe_has_args (result )
197
+ if _args :
198
+ return self .show_args (view , _args )
182
199
183
- return []
200
+ return haxe_completion_list ( result )
184
201
185
202
def show_errors (self , view , errs ):
186
203
0 commit comments