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

testing: add initial editor decorations #202048

Merged
merged 1 commit into from Jan 9, 2024

Conversation

connor4312
Copy link
Member

@connor4312 connor4312 commented Jan 9, 2024

This is the first pass at decorations in-editor. This PR doesn't
actually register the contribution, as it's not ready for selfhosting
yet. This PR creates decorations that look like this. The idea is that
coverage decorations in the glyph margin will always be visibile when
there's coverage, and users can get coverage in their code via hover or
shortcut, with the intention of making coverage unobtrusive and easy to
run all the time.

The notable thing is that there is now a third glyph margin row. I
reworked some of the editor code to handle this.

Some open questions:

  • The glyph margin coverage wants doesn't need to be full-width, should
    we add a new 'leftmost' glyph lane instead that's thinner?

  • Adding breakpoints in files with coverage is a little annoying since
    the breakpoint hint widget can expand the glyph margin on lines with
    coverage, and jump back over otherwise. Probably we should never
    decrease the number of lanes shown whenever the cursor is over the
    glyph margin.

@connor4312 connor4312 self-assigned this Jan 9, 2024
This is the first pass at decorations in-editor. This PR doesn't
actually register the contribution, as it's not ready for selfhosting
yet. This PR creates decorations that look like this. The idea is that
coverage decorations in the glyph margin will always be visibile when
there's coverage, and users can get coverage in their code via hover or
shortcut, with the intention of making coverage unobtrusive and easy to
run all the time.

![](https://memes.peet.io/img/24-01-8e61f4db-f115-4732-affe-59dea879a335.png)

The notable thing is that there is now a third glyph margin row. I
reworked some of the editor code to handle this.

![](https://memes.peet.io/img/24-01-f400369f-650c-4303-be65-e65903f8ad17.png)

Some open questions:

- The glyph margin coverage wants doesn't need to be full-width, should
  we add a new 'leftmost' glyph lane instead that's thinner?
- Adding breakpoints in files with coverage is a little annoying since
  the breakpoint hint widget can expand the glyph margin on lines with
	coverage, and jump back over otherwise. Probably we should never
	decrease the number of lanes shown whenever the cursor is over the
	glyph margin.

		![](https://memes.peet.io/img/24-01-79b53dd9-6fca-41dd-87b5-a113f9c25efb.gif)
@connor4312 connor4312 force-pushed the connor4312/test-coverage-decorations-1 branch from 317aa68 to 0e743a2 Compare January 9, 2024 00:12
@VSCodeTriageBot VSCodeTriageBot added this to the December / January 2024 milestone Jan 9, 2024
Copy link
Member

@alexdima alexdima left a comment

Choose a reason for hiding this comment

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

The changes look good, but I wasn't sure how to test the changes myself? I'm slightly concerned by the jumping around shown in the last gif. Maybe we can also iron that out? Maybe once coverage information is available, the lane count permanently increases for the file.

@connor4312 connor4312 merged commit 801d79e into main Jan 9, 2024
6 checks passed
@connor4312 connor4312 deleted the connor4312/test-coverage-decorations-1 branch January 9, 2024 19:20
connor4312 added a commit that referenced this pull request Jan 9, 2024
In my previous PR #202048, I added another glyph margin lane. However
I didn't realize in some cases the support I added was incomplete since
the rendering code did not fully handle an unbounded number of lanes.

Also, I noticed in existing issues with hover and click handling because
some parts of VS Code still assume there's at most a single glyph widget
visible. It is hard to determine which glyph widget is interacted with
without checking what classes are applied to the glyph element, which
is what most existing code does. And we probably shouldn't do that in
e.g. the MouseHandler to determine what glyph is being clicked on.

So in this PR I added a `GlyphMarginLanesModel` that contains the
information necessary for rendering. I also want to expose it in a place
that the MouseHandler or MouseTarget can get at, but I wasn't sure the
best way to do that, any suggestions @alexdima?

Implementation-wise I opted for a flag Uint8Array. A 1024 line file with
decorations on the last line, it would take 384 bytes to hold decoration
positions. I also tried out a Range array based implementation, but I
think this is faster (for cases where there are lots of decorations)
and much simpler, in exchange for higher memory usage in edge cases
(very long files with decorations near the end.)
connor4312 added a commit that referenced this pull request Jan 9, 2024
In my previous PR #202048, I added another glyph margin lane. However
I didn't realize in some cases the support I added was incomplete since
the rendering code did not fully handle an unbounded number of lanes.

Also, I noticed in existing issues with hover and click handling because
some parts of VS Code still assume there's at most a single glyph widget
visible. It is hard to determine which glyph widget is interacted with
without checking what classes are applied to the glyph element, which
is what most existing code does. And we probably shouldn't do that in
e.g. the MouseHandler to determine what glyph is being clicked on.

So in this PR I added a `GlyphMarginLanesModel` that contains the
information necessary for rendering. I also want to expose it in a place
that the MouseHandler or MouseTarget can get at, but I wasn't sure the
best way to do that, any suggestions @alexdima?

Implementation-wise I opted for a flag Uint8Array. A 1024 line file with
decorations on the last line, it would take 384 bytes to hold decoration
positions. I also tried out a Range array based implementation, but I
think this is faster (for cases where there are lots of decorations)
and much simpler, in exchange for higher memory usage in edge cases
(very long files with decorations near the end.)
connor4312 added a commit that referenced this pull request Jan 9, 2024
In my previous PR #202048, I added another glyph margin lane. However
I didn't realize in some cases the support I added was incomplete since
the rendering code did not fully handle an unbounded number of lanes.

Also, I noticed in existing issues with hover and click handling because
some parts of VS Code still assume there's at most a single glyph widget
visible. It is hard to determine which glyph widget is interacted with
without checking what classes are applied to the glyph element, which
is what most existing code does. And we probably shouldn't do that in
e.g. the MouseHandler to determine what glyph is being clicked on.

So in this PR I added a `GlyphMarginLanesModel` that contains the
information necessary for rendering. I also want to expose it in a place
that the MouseHandler or MouseTarget can get at, but I wasn't sure the
best way to do that, any suggestions @alexdima?

Implementation-wise I opted for a flag Uint8Array. A 1024 line file with
decorations on the last line, it would take 384 bytes to hold decoration
positions. I also tried out a Range array based implementation, but I
think this is faster (for cases where there are lots of decorations)
and much simpler, in exchange for higher memory usage in edge cases
(very long files with decorations near the end.)
connor4312 added a commit that referenced this pull request Jan 10, 2024
* monaco: improve handling of glyph margins

In my previous PR #202048, I added another glyph margin lane. However
I didn't realize in some cases the support I added was incomplete since
the rendering code did not fully handle an unbounded number of lanes.

Also, I noticed in existing issues with hover and click handling because
some parts of VS Code still assume there's at most a single glyph widget
visible. It is hard to determine which glyph widget is interacted with
without checking what classes are applied to the glyph element, which
is what most existing code does. And we probably shouldn't do that in
e.g. the MouseHandler to determine what glyph is being clicked on.

So in this PR I added a `GlyphMarginLanesModel` that contains the
information necessary for rendering. I also want to expose it in a place
that the MouseHandler or MouseTarget can get at, but I wasn't sure the
best way to do that, any suggestions @alexdima?

Implementation-wise I opted for a flag Uint8Array. A 1024 line file with
decorations on the last line, it would take 384 bytes to hold decoration
positions. I also tried out a Range array based implementation, but I
think this is faster (for cases where there are lots of decorations)
and much simpler, in exchange for higher memory usage in edge cases
(very long files with decorations near the end.)

* allow lanes to be persisted to avoid jumping bp icons
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