Hi, as the title says I have difficulties working with the gutter, and maybe that’s because I don’t understand the new version 6 concepts in all detail.
I’m working on a code review tool and it’ll be possible to write a comment for multiple lines of code (these comments are not shown inside the editor though). My goal is to show the number of comments per piece of code in the gutter and highlight the gutter for all the lines that have comments.
Here’s what I have so far:
There’s one comment each starting at line 2 and 4. And there are two (not eleven!) comments starting at line 1. Right now I’m simply adding a new instance of my GutterMarker subclass to the markers RangeSet with a hard-coded “1” and CM is just appending the element.
This is obviously wrong, and it’s where I’m kinda stuck. I did manage to solve it at some point and I can certainly go back to that solution.
So, what I’m actually asking is what would be an appropriate approach for this that works well with CM’s underlying concepts?
My ideas so far:
- (This one I had implemented) Keep a list of comments in a StateField and every time it changes or something else is happening (like I want to highlight some comment related markers) I iterate over and re-process everything. But this seems wasteful.
- Add GutterMarker instances to every single line and somehow address each one individually to change its content and style. But how to address them, I couldn’t find a way to get a list of those markers anywhere.
I also have trouble understanding how GutterMarker, Range and RangeSet relate to each other, and even a list of RangeSet that can be returned from the markers function, especially because a GutterMarker apparently can only refer to a single line, not multiple.
So, I hope you can help me out