Skip to content

Commit

Permalink
also restore regions being auto-highlighted
Browse files Browse the repository at this point in the history
  • Loading branch information
tomv564 committed Nov 4, 2015
1 parent d7ab889 commit 8d7be70
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion test/test_listeners.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def test_type_at_cursor_tests(self):
listener.on_selection_modified(view)

view.set_status.assert_called_with("type_at_cursor", type_info)
#view.add_regions.assert_called_with("type_at_cursor", ANY, "storage.type", "", sublime.DRAW_OUTLINED)
view.add_regions.assert_called_with("type_at_cursor", ANY, "storage.type", "", sublime.DRAW_OUTLINED)

def test_request_completions(self):

Expand Down
2 changes: 1 addition & 1 deletion test/test_win.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def test_highlight_type_clear(self):
Win(window).highlight_type([])

view.set_status.assert_called_with("type_at_cursor", "")
#view.add_regions.assert_called_with("type_at_cursor", [], "storage.type", "", sublime.DRAW_OUTLINED)
view.add_regions.assert_called_with("type_at_cursor", [], "storage.type", "", sublime.DRAW_OUTLINED)

def test_highlight_no_errors(self):

Expand Down
5 changes: 3 additions & 2 deletions text_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ def run(self,edit):
def _handle_response(self,response):
type_spans = list(parse_exp_types(response))
if type_spans:
_type = next(filter_enclosing(self.view, self.view.sel()[0], type_spans), None)
if not _type is None:
type_span = next(filter_enclosing(self.view, self.view.sel()[0], type_spans), None)
if type_span is not None:
_type, span = type_span
self.view.show_popup(_type)


Expand Down
2 changes: 1 addition & 1 deletion utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def within(smaller, larger):
return smaller.begin() >= larger.begin() and smaller.end() <= larger.end()

def filter_enclosing(view, region, span_pairs):
return (item for item, span in span_pairs if within(region, view_region_from_span(view, span)))
return ((item, span) for item, span in span_pairs if within(region, view_region_from_span(view, span)))

def shorten_module_prefix(prefixed_type):
words = prefixed_type.split('.')
Expand Down
9 changes: 5 additions & 4 deletions win.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,19 @@ def highlight_type(self, exp_types):
type_spans = list(parse_exp_types(exp_types))
if type_spans:
view = self.window.active_view()
_type = next(filter_enclosing(view, view.sel()[0], type_spans), None)
if not _type is None:
type_span = next(filter_enclosing(view, view.sel()[0], type_spans), None)
if type_span is not None:
(_type, span) = type_span
view.set_status("type_at_cursor", _type)
#view.add_regions("type_at_cursor", [view_region_from_span(view, span)], "storage.type", "", sublime.DRAW_OUTLINED)
view.add_regions("type_at_cursor", [view_region_from_span(view, span)], "storage.type", "", sublime.DRAW_OUTLINED)
if Win.show_popup:
view.show_popup(shorten_module_prefix(_type))
return

# Clear type-at-cursor display
for view in self.window.views():
view.set_status("type_at_cursor", "")
# view.add_regions("type_at_cursor", [], "storage.type", "", sublime.DRAW_OUTLINED)
view.add_regions("type_at_cursor", [], "storage.type", "", sublime.DRAW_OUTLINED)


def handle_source_errors(self, source_errors):
Expand Down

0 comments on commit 8d7be70

Please sign in to comment.