-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Bump mac editor and implement CocoaTextBufferVisibilityTracker #65568
Bump mac editor and implement CocoaTextBufferVisibilityTracker #65568
Conversation
src/EditorFeatures/Core.Cocoa/Workspaces/CocoaTextBufferVisibilityTracker.cs
Outdated
Show resolved
Hide resolved
I tried multiple ways of fixing the duplication, but I end up with an issue where Can we take this as-is for now? |
This should help reduce the number classification marks triggering in the editor in VSMac. Fixes https://dev.azure.com/devdiv/DevDiv/_workitems/edit/1654358
aa12f5a
to
60505e5
Compare
@Therzok Sorry, i should have been more clear on how to do it. I've made the changed and pushed to your branch. Let me know how it looks for you. |
eng/Versions.props
Outdated
@@ -28,7 +28,7 @@ | |||
<VisualStudioEditorPackagesVersion>17.5.42-preview</VisualStudioEditorPackagesVersion> | |||
<!-- This should generally be set to $(VisualStudioEditorPackagesVersion), | |||
but sometimes EditorFeatures.Cocoa specifically requires a newer editor build. --> | |||
<VisualStudioMacEditorPackagesVersion>17.3.133-preview</VisualStudioMacEditorPackagesVersion> | |||
<VisualStudioMacEditorPackagesVersion>17.5.152-preview-g356e9d7141</VisualStudioMacEditorPackagesVersion> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@genlu @allisonchou what branch should this go into? main-vs-deps?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should be able to bump this to a standard daily build version, yes (won't have a commit hash suffix)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this is a package from a PR build. Let's change this to 17.5.157-preview (or 17.5.170-preview if we want latest).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually VisualStudioEditorPackagesVersion
should be bumped and this property's value should be changed to $(VisualStudioEditorPackagesVersion)
. But that can happen in another PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given this (hopefully?) only affects Mac we shouldn't need to worry about vs-deps. If we did bump VisualStudioEditorPackagesVersion
then we might
{ | ||
private readonly ITextBufferAssociatedViewService _associatedViewService; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all this moved to abstract base class.
where TTextView : ITextView | ||
where TVisibilityChangedCallback : System.Delegate | ||
{ | ||
private readonly ITextBufferAssociatedViewService _associatedViewService; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all this state and logic is the same. just pulled up into base class. i have marked where they differ.
protected abstract bool IsVisible(TTextView view); | ||
protected abstract TVisibilityChangedCallback GetVisiblityChangeCallback(VisibleTrackerData visibleTrackerData); | ||
protected abstract void AddVisibilityChangedCallback(TTextView view, TVisibilityChangedCallback visibilityChangedCallback); | ||
protected abstract void RemoveVisibilityChangedCallback(TTextView view, TVisibilityChangedCallback visibilityChangedCallback); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
abstract functionality for where wpf and cocoa need to specialize.
if (views.Any(static v => v is not TTextView)) | ||
return true; | ||
|
||
return views.OfType<TTextView>().Any(v => IsVisible(v)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
defer to IsVisible here to do platform specific determination.
{ | ||
_tracker = tracker; | ||
_subjectBuffer = subjectBuffer; | ||
_visibilityChangedCallback = tracker.GetVisiblityChangeCallback(this); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
defer to platform specific code to get the callback with which to register to visibility changed event.
foreach (var addedView in addedViews) | ||
{ | ||
if (addedView is TTextView genericView) | ||
_tracker.AddVisibilityChangedCallback(genericView, _visibilityChangedCallback); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
defer to platform specific code to attach/detach the visibility changed listener.
@jasonmalinowski ptal. |
{ | ||
_tracker._threadingContext.ThrowIfNotOnUIThread(); | ||
protected override EventHandler GetVisiblityChangeCallback(VisibleTrackerData visibleTrackerData) | ||
=> (sender, args) => visibleTrackerData.TriggerCallbacks(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, heh, I didn't think of wrapping in the derived impl.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the changes!
No worries! The problem I was having is that I didn't have a plain EventHandler. My WIP work was similar to this, except that I was doing generic work over the event args, rather than the eventhandler delegate itself. Thanks for fixing it up. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, should just probably bump the editor package to a standard build instead of a PR build. 17.5.157-preview is the first that has the necessary changes. 17.5.170-preview is the latest that currently exists.
Yeah, sorry, I was using a PR build to be able to validate the changes first. |
This should help reduce the number classification marks triggering in the editor in VSMac. Fixes https://dev.azure.com/devdiv/DevDiv/_workitems/edit/1654358 Backport of #65568 without the refactoring.
@CyrusNajmabadi @davidwengier can we merge this now? |
yup yup! |
This should help reduce the number classification marks triggering in the editor in VSMac.
Uses newly added API in VS-Platform, 0f93736f636b83a30c3a0b393b89afbe882de5e3.
Fixes https://dev.azure.com/devdiv/DevDiv/_workitems/edit/1689011