From fdd6315d46b7c1984771bff95d03fda608a5c311 Mon Sep 17 00:00:00 2001 From: zhengbli Date: Tue, 11 Oct 2016 17:31:23 -0700 Subject: [PATCH 1/2] Support inline error tooltip at cursor position --- typescript/commands/error_info.py | 10 +++++++--- typescript/libs/global_vars.py | 2 ++ typescript/listeners/idle.py | 7 +++++-- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/typescript/commands/error_info.py b/typescript/commands/error_info.py index 3bca42aa..385984dc 100644 --- a/typescript/commands/error_info.py +++ b/typescript/commands/error_info.py @@ -21,7 +21,11 @@ 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") \ No newline at end of file + if PHANTOM_SUPPORT: + template = '
{0}
' + display_text = template.format(error_text) + self.view.add_phantom("typescript_error", self.view.sel()[0], display_text, sublime.LAYOUT_BLOCK) + else: + self.view.set_status("typescript_error", error_text) \ No newline at end of file diff --git a/typescript/libs/global_vars.py b/typescript/libs/global_vars.py index 84e45f2b..5f9f789c 100644 --- a/typescript/libs/global_vars.py +++ b/typescript/libs/global_vars.py @@ -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 diff --git a/typescript/listeners/idle.py b/typescript/listeners/idle.py index 6b4d714d..d4d25917 100644 --- a/typescript/listeners/idle.py +++ b/typescript/listeners/idle.py @@ -169,11 +169,14 @@ 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 info.has_errors: - view.run_command('typescript_error_info') + if PHANTOM_SUPPORT: + view.erase_phantoms("typescript_error") else: view.erase_status("typescript_error") + if info.has_errors: + view.run_command('typescript_error_info') + # Quick info error_status = view.get_status('typescript_error') if error_status and len(error_status) > 0: From f43298f3fd085cfec762a746f78b4e6cf2c8671a Mon Sep 17 00:00:00 2001 From: zhengbli Date: Wed, 26 Oct 2016 17:19:31 -0700 Subject: [PATCH 2/2] set error tooltip text color too and always update status bar --- typescript/commands/error_info.py | 5 ++--- typescript/listeners/idle.py | 3 +-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/typescript/commands/error_info.py b/typescript/commands/error_info.py index 385984dc..f220c995 100644 --- a/typescript/commands/error_info.py +++ b/typescript/commands/error_info.py @@ -24,8 +24,7 @@ def run(self, text): if len(error_text) > 0: if PHANTOM_SUPPORT: - template = '
{0}
' + template = '
{0}
' display_text = template.format(error_text) self.view.add_phantom("typescript_error", self.view.sel()[0], display_text, sublime.LAYOUT_BLOCK) - else: - self.view.set_status("typescript_error", error_text) \ No newline at end of file + self.view.set_status("typescript_error", error_text) \ No newline at end of file diff --git a/typescript/listeners/idle.py b/typescript/listeners/idle.py index d4d25917..687e3a76 100644 --- a/typescript/listeners/idle.py +++ b/typescript/listeners/idle.py @@ -171,8 +171,7 @@ def update_status(self, view, info): # Error info if PHANTOM_SUPPORT: view.erase_phantoms("typescript_error") - else: - view.erase_status("typescript_error") + view.erase_status("typescript_error") if info.has_errors: view.run_command('typescript_error_info')