Skip to content

Conversation

@Cosifne
Copy link
Member

@Cosifne Cosifne commented Aug 17, 2021

Snapshot after this change:
after3

I have been thinking about this change for a long time.
Right now InheritanceMargin is using the GlyphMargin provided by the Editor.
And it leads to several problems.

  1. Inheritance margin interferes with breakpoints #55353
    Breakpoint overlapping issue. Because we are sharing the margin with breakpoint, so either we handle the click event or breakpoint handle it. (Right now we are always handling it)

If we yield to the event to breakpoint, I still found some unwanted scenarios:
I. image
If breakpoint handles the click then the inheritance margin won't be clickable

Also as Fred mentioned, if some other plugin (VsVim) is also using the GlyphMargin, it becomes very crowded.

  1. Inheritance Margin Icons are too small #53401
    The side of the margin is controlled by the editor now, if we moved this to our own column we can then make it larger. (Maybe to match the size of light bulb)

  2. Clicking on inheritance margin does not open up (potentially due to VS being in Chinese) #53708
    The current solution is to disable Resharper, but what I guess is Resharper is providing its own GlyphMarginProvider so it catches the mouse click event, which can cause the inheritance margin non-clickable.

Other minor issues benefited from this:

  1. [Inheritance Margin] Don't get the margin for items from metadata #53375
    Because currently, editor owns the life cycle of the glyph, if we move to our own view margin, then we can make the margin visible even when the text is collapsed.

@Cosifne Cosifne requested a review from a team August 17, 2021 17:31
@ghost ghost added the Area-IDE label Aug 17, 2021

namespace Microsoft.VisualStudio.LanguageServices.Implementation.InheritanceMargin.MarginGlyph
{
internal class InheritanceMarginGlyphViewModel
Copy link
Member Author

Choose a reason for hiding this comment

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

No change, just rename


namespace Microsoft.VisualStudio.LanguageServices.Implementation.InheritanceMargin.MarginGlyph
{
internal partial class InheritanceMarginGlyph
Copy link
Member Author

Choose a reason for hiding this comment

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

No change, just rename

@sharwell
Copy link
Contributor

sharwell commented Aug 17, 2021

I super don't like this. The breakpoints margin is always empty and I don't like more space taken up for something I never use.

❓ How difficult is it to make this an option?

@Cosifne
Copy link
Member Author

Cosifne commented Aug 17, 2021

I super don't like this. The breakpoints margin is always empty and I don't like more space taken up for something I never use.

❓ How difficult is it to make this an option?

This PR is for demo purposes to show the problem and how it looks like after the change.
If we have it as an option.
Like. option-> show inheritance margin in -> Left Margin
Right Margin
etc...
We will need help from the editor. From the API perspective, a MEF metadata attribute is needed (indicate all the possible margin) And a Roslyn option service to notify them of the options change.

@CyrusNajmabadi
Copy link
Member

I'm fine witht his as a demo. But please don't check in otherwise if this changes the current behavior (which is great) :)

@sharwell sharwell marked this pull request as draft August 17, 2021 20:47
@Cosifne
Copy link
Member Author

Cosifne commented Aug 17, 2021

I'm fine witht his as a demo. But please don't check in otherwise if this changes the current behavior (which is great) :)

Sam found a way to make this optional. (which makes the position could be configured in the Options page)
We are working on this

@sharwell
Copy link
Contributor

I totally did 😎

@sharwell
Copy link
Contributor

InheritanceMarginOptions

@Cosifne
Copy link
Member Author

Cosifne commented Aug 20, 2021

OK, I finally figure out a good way to implement the two options, and not use any hack. (with a little perf cost)
after3
And huge thanks to Sam for his starting idea

Copy link
Member

@CyrusNajmabadi CyrusNajmabadi left a comment

Choose a reason for hiding this comment

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

Overall looks really good. just some cleanup suggesitons.

_glyphsContainer.Children.Remove(glyph);
}

var remainingGlyphData = _glyphDataTree.Except(glyphDataToRemove).ToImmutableArray();
Copy link
Member Author

Choose a reason for hiding this comment

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

I looked how the Tagger remove item from the interval tree here https://sourceroslyn.io/#Microsoft.CodeAnalysis.EditorFeatures/Tagging/AbstractAsynchronousTaggerProvider.TagSource_ProduceTags.cs,369
But not sure if this is the correct way to do it here.
@CyrusNajmabadi for verify

@Cosifne Cosifne requested a review from CyrusNajmabadi August 26, 2021 06:16
@Cosifne
Copy link
Member Author

Cosifne commented Aug 26, 2021

@CyrusNajmabadi Ready to have another round of reviewing

// so in order to get the glyphs removed when FeatureOnOffOptions.InheritanceMarginCombinedWithIndicatorMargin is off,
// we need
// 1. Generate tags when this option changes.
// 2. Always return null here to force the editor to remove the glyphs.
Copy link
Member

Choose a reason for hiding this comment

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

👍


void IDisposable.Dispose()
{
_editorFormatMap.FormatMappingChanged -= FormatMappingChanged;
Copy link
Member

Choose a reason for hiding this comment

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

consider a threading assert for this method as well. (but it's ok to elave out).

private readonly IEditorFormatMap _editorFormatMap;
private readonly IAsynchronousOperationListener _listener;
private readonly Canvas _glyphsContainer;
private readonly SimpleIntervalTree<GlyphData, GlyphDataIntrospector> _glyphDataTree;
Copy link
Member

Choose a reason for hiding this comment

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

noice.

_glyphDataTree.Clear();
foreach (var (span, glyph) in allGlyphData)
{
var newSpan = span.TranslateTo(snapshot, SpanTrackingMode.EdgeInclusive);
Copy link
Member

Choose a reason for hiding this comment

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

so we have TagSpanIntervalTree. can you look if that would make your life easier?

Copy link
Member Author

Choose a reason for hiding this comment

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

It seems like TagSpanIntervalTree is tracking the position of the the tag, but here I need a data structure that could also track the glyphs.
So far I feel SimpleIntervalTree is fine.

Copy link
Member

@CyrusNajmabadi CyrusNajmabadi left a comment

Choose a reason for hiding this comment

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

tentatively approving. please do look into TagSpanIntervalTree as i think it coul dhelp.

also, if we don't have it, we really need some integration tests. once this goes in, please front load work to at least get a basic test in place for both styles of inheritance margin (merged and non-merged).

@Cosifne
Copy link
Member Author

Cosifne commented Aug 26, 2021

tentatively approving. please do look into TagSpanIntervalTree as i think it coul dhelp.

also, if we don't have it, we really need some integration tests. once this goes in, please front load work to at least get a basic test in place for both styles of inheritance margin (merged and non-merged).

Once I resolve the comments here I would try to find vendors to test this before checked in.

@Cosifne Cosifne merged commit 94d1ae5 into dotnet:main Aug 31, 2021
@ghost ghost added this to the Next milestone Aug 31, 2021
@dibarbet dibarbet modified the milestones: Next, 17.0.P4 Aug 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants