Skip to content

Commit fd64997

Browse files
committed
Growing function bug fixed
1 parent 7d546bd commit fd64997

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99

1010
* Fixed error in big_roi module , where when trying to select something in global scope with vertical direction big_roi_queries ,not checking for Nonetype object caused error
1111

12+
* Fixed error in the preliminary function of the big regions of interest, where if the cursor was at the last empty line of the function, selections would be given from the next function!
13+
14+
* Fixed old name of my output panel:)
15+
1216
### Changed
1317

1418
* collection queries no labels not to now have labels(names) and they display them

library/repair.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,12 +300,24 @@ def correct_start_of_line(self,atok,token,before_information,after_information):
300300
p = previous_token(atok, token)
301301
n = next_token(atok,token)
302302

303+
def handle_error(self,atok, token):
304+
if token in self.already_checked:
305+
return True
306+
final_error = token
307+
return False
308+
while final_error.type==token.ERRORTOKEN:
309+
self.already_checked.add(final_error)
310+
final_error = next_token(atok,final_error)
311+
final_error = previous_token(atok, token)
312+
313+
303314

304315

305316
def work(self):
306317
l = LineInfo(self.atok)
307318
b = BracketMatcher(self.atok)
308319
k = 0
320+
self.already_checked = set()
309321
for t in self.atok.tokens:
310322
if t.string in ["if","for","while","with","def","elif","else"]:
311323
if t.string == "elif":
@@ -315,6 +327,9 @@ def work(self):
315327
self.m.modify_from(self.start_time,(z[1],z[1]),z[2])
316328
if z[3]:
317329
continue
330+
if t.type==token.ERRORTOKEN :
331+
if self.handle_error(self.atok, t):
332+
continue
318333
x,y = process_token(self.atok,t,l,b)
319334
if x[0]:
320335
self.insert_before(t,x[1])

queries/big_roi.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,15 @@ def preliminary(self,view_information,query_description, extra = {}):
3131
origin = nearest_node_from_offset(root,atok, selection[0]) if selection[0]==selection[1] else node_from_range(root,atok, selection)
3232
definition_node = search_upwards(origin,ast.FunctionDef) # need to change that in the future
3333
# in order to find the outermost function.
34-
definition_node = ( definition_node
34+
if definition_node and definition_node.first_token.startpos> selection[1]:
35+
token = atok.get_token_from_offset(selection[0])
36+
while token.string.isspace():
37+
token = atok.prev_token( token )
38+
s = token.startpos
39+
origin = nearest_node_from_offset(root,atok, s)
40+
definition_node = search_upwards(origin,ast.FunctionDef)
41+
definition_node = (
42+
definition_node
3543
if definition_node and query_description["big_roi"] not in ["import statement"]
3644
else root
3745
)

0 commit comments

Comments
 (0)