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

Fix and improve "type at cursor" command; show errors in phantoms #20

Open
wants to merge 20 commits into
base: master
Choose a base branch
from

Conversation

bluepichu
Copy link

@bluepichu bluepichu commented Sep 3, 2017

Don't merge this, it's not ready yet! I just wanted to make sure it was on your radar before it's done.

Hi there! I found this package in my preparation to do a bunch of OCaml dev in Sublime. I'm glad it's here :)

However, I found that the "type at cursor" text command didn't seem to work, and the related context menu command was kind of lacking. This PR should provide a better interface for accessing types. While I was doing this, I also moved errors into phantoms to get rid of bottom pop-up altogether.

Here are my changes in action on a sample cat program:

New type command demo

Important caveat: this DOES NOT work properly in the current "stable" version of ST3, since phantoms have a major bug that sometimes causes them to display the incorrect content. However, it does work properly on the latest dev build. UPDATE: A new stable ST3 just got released that fixed this bug.

Remaining to-do

  • Figure out if there's a way to limit the width of a phantom - otherwise warnings/errors sometimes run offscreen
  • Decide the best way to highlight error/warning regions (currently it's using an underline, but that's sometimes confusing)
  • Fix the gutter dot color for warnings
  • Add a command to "expand" the currently-displayed type
  • General cleanup

@bluepichu
Copy link
Author

I didn't realize it, but this would close #19 I suppose.

@let-def
Copy link
Contributor

let-def commented Sep 14, 2017

That looks very cool! I am tempted to switch to st3 :)

@cynddl
Copy link
Owner

cynddl commented Sep 17, 2017

Hey @bluepichu, thank you for taking time to contribute to this project! Let me know when I can start reviewing your changes. 🙌

@bluepichu bluepichu changed the title WIP: Fix and improve "type at cursor" command; show errors in phantoms Fix and improve "type at cursor" command; show errors in phantoms Sep 24, 2017
@bluepichu
Copy link
Author

@cynddl - you can review this whenever you're ready :)

@cynddl
Copy link
Owner

cynddl commented Sep 25, 2017

@bluepichu Great work! I made a few cosmetic changes and one fix (3bf022d):

  1. (cosmetic) update HTML string interpolation to Python "".format() syntax
  2. (cosmetic) rename show_errors and display_errors functions,
  3. (cosmetic) use os.path.join instead of manually concatenating paths,
  4. (fix) the selection under the cursor was not working when the cursor was exactly at the beginning or the end of a word. I relaxed the selection.

I feel like the main file is getting bigger and bigger and would appreciate if we can separate display functionalities (eg. showing phantoms) from commands and event listeners. Maybe by creating a merlin/phantom.py file with all the display-related code. Let me know if you can do that, otherwise I'll see if I have time this week.

Thanks again! 🎉

@bluepichu
Copy link
Author

Hi @cynddl -- looks great! I definitely won't have time for the remainder of this week, so definitely don't wait on me for any restructuring you want to do.

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.

4 participants