Skip to content
This repository was archived by the owner on Dec 17, 2025. It is now read-only.

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

Open
bluepichu wants to merge 20 commits into
cynddl:masterfrom
bluepichu:master
Open

Fix and improve "type at cursor" command; show errors in phantoms#20
bluepichu wants to merge 20 commits into
cynddl:masterfrom
bluepichu:master

Conversation

@bluepichu

@bluepichu bluepichu commented Sep 3, 2017

Copy link
Copy Markdown

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
Copy Markdown
Author

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

@let-def

let-def commented Sep 14, 2017

Copy link
Copy Markdown
Contributor

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

@cynddl

cynddl commented Sep 17, 2017

Copy link
Copy Markdown
Owner

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
Copy Markdown
Author

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

@cynddl

cynddl commented Sep 25, 2017

Copy link
Copy Markdown
Owner

@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
Copy Markdown
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 subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants