Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support inline error tooltip at cursor position #546

Merged
merged 2 commits into from Oct 27, 2016
Merged

Conversation

zhengbli
Copy link
Contributor

@zhengbli zhengbli commented Oct 12, 2016

The added behavior is quite similar to what we had before. But when the sublime version supports Phantom APIs (> 3118), we show a phantom popup instead of put the error message at the status bar (only after you click). The popup will go away when either the error is fixed or when the cursor (the keyboard cursor not the mouse cursor) moved to somewhere else. While the "on_hover" tooltip will always show the quick info.

In summary, the workflow is:

  • hover with your mouse cursor to get quick info
  • click at an error position to see error messages
  • errors messages will appear when keyboard cursor is on top of an error span
  • click elsewhere to dismiss an error message

gif

if PHANTOM_SUPPORT:
template = '<body><style>div.error {{ background-color: brown; padding: 5px; }}</style><div class="error">{0}</div></body>'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the coloring change at all with the themes? Seeing as you only set background here, and not foreground, could foreground ever default to something in some themes which is unreadable?

template = '<body><style>div.error {{ background-color: brown; padding: 5px; }}</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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting I don't see add_phantom on the view class in the docs (https://www.sublimetext.com/docs/3/api_reference.html#sublime.View). Maybe an oversight. They didn't make changes to this API after introducing it right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah it still exists in the latest version. I learnt it from the example at:
https://forum.sublimetext.com/t/dev-build-3118/21270

if PHANTOM_SUPPORT:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If show_errors_inline is set to false, do phantoms still appear? As this is an if/else, that would mean no error info. Is there a downside to always updating the status bar anyway?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, show_errors_inline only affects sublime's own error tips, it doesn't toggle all phantom tooltips. Though I agree we can always update the status bar anyway.

@billti
Copy link
Member

billti commented Oct 27, 2016

👍

@zhengbli zhengbli merged commit c950495 into master Oct 27, 2016
@zhengbli zhengbli deleted the inlineError branch October 27, 2016 00:23
@camloken
Copy link

It would be cool if you could place links in the tooltip that take you to the website rule. Atom does this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants