-
Notifications
You must be signed in to change notification settings - Fork 300
Feature/Color layer #2413
Feature/Color layer #2413
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2413 +/- ##
==========================================
+ Coverage 38.23% 38.26% +0.02%
==========================================
Files 300 300
Lines 12530 12537 +7
Branches 1650 1650
==========================================
+ Hits 4791 4797 +6
- Misses 7484 7485 +1
Partials 255 255
Continue to review full report at Codecov.
|
I think leaving this for a second PR makes sense, but just in case its useful, have you considered trying to use the text mate grammar scopes for this? You could potentially restrict it to just strings etc. I've just given it a try, and looks good! Only two comments I have are potentially adding some error checking, and how the layers are applied to the editor, though I expect that is an API question. I added The second point is more about the API I think, but due to this being a layer that sits on top, the cursor is hidden when it enters the string, meaning you can't actually see where you are in the string. (I can just about see the cursor since the highlight box doesn't seem to be exactly aligned with the cursor, but still). |
@CrossR thanks for trying this out 👍, tbh for this first thought was using a grammar but tbh I think it will make this process way more expensive I created what should be fairly multi purpose I think this regex is fairly sound but just needs a tweak for the edge case, it could turn out to not be the case in the long term but for now the process is way more straightforward, I can have a go later on to see how it can be tweaked. Re. the cursor thats a very good point I didn't realise that. I didn't put a Re. the vim filetype error can I ask what the error was I'm not sure what case would have caused the error there the function should only run if the file hits any color matches |
@CrossR thanks that helps pretty sure it might be that the colors that are defined are defined with caps so it correctly matches them but the color that is passed to the highlight is |
Pushed a fix and tested it out in Edit: Also upped the |
Small explainer of added changes slightly unrelated changes, because of the cursor hiding issue I added a |
Just got a chance to test this out! And tweeted about it 😄 Looks awesome @akin909 ! And thanks for your help testing it, @CrossR ! Nice catch on the crash with One thing we'll have to keep in mind with the buffer layers is performance (they have the potential to cost extra perf, since their rendering is triggered frequently - ie, anytime the cursor position changes). So far it seems like we're in good shape - ran this through the profiler (and I also have indent guides), and I didn't see much impact. No action needed there, just something I was thinking about. Really appreciate the test, too @akin909 ! Looks good to me! 💯 |
Having had a go at implementing a layer in #2344, I've also implemented a layer to highlight css colors in certain files. The way that this works is that if a file extension is in the whitelist any hex/rgba/hsla color is colored.
Todos:
rebeccapurple, goldenrod
etc.Outstanding Issues:
- The layer renders on top of the renderer so the color highlight lies on top of the text obscuring the syntax highlight, currently I reduce the colors opacity but this actually changes the color so its not quite accurate- Potentially I could put the matching color into the element but set the
color
prop to transparent so it makes a word shaped window 😆- Another idea would be just to render the text inside the highlight using the user's font
This is a tough one as its beyond my abilities with regex to not break the regex but have it fail if it matches inside another word I think possibly using some sort of word boundary
\\b
check might work but would rather not try and fix this right off the bat as its a potential rabbit hole.