Skip to content

Commit

Permalink
JumpToDependency: Jump to a singular-path on a line
Browse files Browse the repository at this point in the history
  • Loading branch information
Joel Kemp committed May 1, 2015
1 parent 1893293 commit dac49e5
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion JumpToDependency.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,22 +134,32 @@ def get_selected_module_region(self):
selected_region = self.view.word(region)
selected_line = self.view.line(region)

print('region', selected_region)
print('line', selected_line)

line = self.view.substr(selected_line)
pattern = '[\'"]{1}([^"\']*)[\'"]{1}'
strings_on_line = re.findall(pattern, line)

print('on_line', strings_on_line)
if not len(strings_on_line):
cant_find_file()
return

# Get the locations of the strings within the buffer
regions = map(lambda string: self.view.find_all(string), strings_on_line)
regions = flatten(list(regions))
print('regions', regions)
# Get the regions that intersect with the clicked region
region = list(filter(lambda r: r.contains(selected_region), regions))

if not len(region):
return None
# If they didn't click within the line and there's a path
# on the line, just use the path
if len(regions) == 1:
region = regions
else:
return None

return region[0]

Expand Down

0 comments on commit dac49e5

Please sign in to comment.