Skip to content

Commit

Permalink
Merge pull request #546 from Microsoft/inlineError
Browse files Browse the repository at this point in the history
Support inline error tooltip at cursor position
  • Loading branch information
zhengbli committed Oct 27, 2016
2 parents 3475f8f + f43298f commit c950495
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
9 changes: 6 additions & 3 deletions typescript/commands/error_info.py
Expand Up @@ -21,7 +21,10 @@ def run(self, text):
if region.contains(pt):
error_text = text
break

if len(error_text) > 0:
self.view.set_status("typescript_error", error_text)
else:
self.view.erase_status("typescript_error")
if PHANTOM_SUPPORT:
template = '<body><style>div.error {{ background-color: brown; padding: 5px; color: white }}</style><div class="error">{0}</div></body>'
display_text = template.format(error_text)
self.view.add_phantom("typescript_error", self.view.sel()[0], display_text, sublime.LAYOUT_BLOCK)
self.view.set_status("typescript_error", error_text)
2 changes: 2 additions & 0 deletions typescript/libs/global_vars.py
Expand Up @@ -42,6 +42,8 @@ def get_tsc_path():
# only Sublime Text 3 build after 3072 support tooltip
TOOLTIP_SUPPORT = int(sublime.version()) >= 3072

PHANTOM_SUPPORT = int(sublime.version()) >= 3118

# detect if quick info is available for symbol
SUBLIME_WORD_MASK = 515

Expand Down
6 changes: 4 additions & 2 deletions typescript/listeners/idle.py
Expand Up @@ -169,10 +169,12 @@ def show_errors(self, diagno_event_body, syntactic):
def update_status(self, view, info):
"""Update the status line with error info and quick info if no error info"""
# Error info
if PHANTOM_SUPPORT:
view.erase_phantoms("typescript_error")
view.erase_status("typescript_error")

if info.has_errors:
view.run_command('typescript_error_info')
else:
view.erase_status("typescript_error")

# Quick info
error_status = view.get_status('typescript_error')
Expand Down

0 comments on commit c950495

Please sign in to comment.