Skip to content

Commit

Permalink
fix type prefix shortening
Browse files Browse the repository at this point in the history
  • Loading branch information
rvion committed Nov 15, 2015
1 parent 8d7be70 commit 69de0fa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 4 additions & 0 deletions utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ def within(smaller, larger):
def filter_enclosing(view, region, span_pairs):
return ((item, span) for item, span in span_pairs if within(region, view_region_from_span(view, span)))

def shorten_module_prefixes(type_with_prefixes):
words = type_with_prefixes.replace("(", " ( ").replace("[", " [ ").split(' ')
return (" ".join(map(shorten_module_prefix, words)).replace(" ( ","(").replace(" [ ","["))

def shorten_module_prefix(prefixed_type):
words = prefixed_type.split('.')
if (len(words) > 1):
Expand Down
6 changes: 2 additions & 4 deletions win.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import sublime
except ImportError:
from test.stubs import sublime
from utility import first_folder, view_region_from_span, filter_enclosing, shorten_module_prefix
from utility import first_folder, view_region_from_span, filter_enclosing, shorten_module_prefixes
from response import parse_source_errors, parse_exp_types

class Win:
Expand Down Expand Up @@ -49,7 +49,7 @@ def highlight_type(self, exp_types):
view.set_status("type_at_cursor", _type)
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))
view.show_popup(shorten_module_prefixes(_type))
return

# Clear type-at-cursor display
Expand Down Expand Up @@ -137,5 +137,3 @@ def highlight_errors(self, errors):
for view in self.window.views():
view.add_regions("errors", error_regions_by_view_id.get(view.id(), []), "invalid", "dot", sublime.DRAW_OUTLINED)
view.add_regions("warnings", warning_regions_by_view_id.get(view.id(), []), "comment", "dot", sublime.DRAW_OUTLINED)


0 comments on commit 69de0fa

Please sign in to comment.