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

track non roslyn text buffer changes as well as roslyn text buffer chang... #2515

Merged
merged 4 commits into from
May 7, 2015

Conversation

heejaechang
Copy link
Contributor

...es to delay solution crawler

There are 2 things incremental processor takes care of

@1 is making sure we delay processing any work until there is enough idle (ex, typing) in host.
@2 is managing cancellation and pending works.

we used to do #1 and #2 only for Roslyn files. and that is usually fine since most of time solution contains only roslyn files.

but for mixed solution (ex, Roslyn files + HTML + JS + CSS), #2 still makes sense but #1 doesn't. We want to pause any work while something is going on in other project types as well.

we need to make sure we play nice with neighbors as well.

now, we don't care where changes are coming from. if there is any change in host, we puase oursevles for a while.

…anges to delay solution crawler

There are 2 things incremental processor takes care of

@1 is making sure we delay processing any work until there is enough idle (ex, typing) in host.
@2 is managing cancellation and pending works.

we used to do #1 and #2 only for Roslyn files. and that is usually fine since most of time solution contains only roslyn files.

but for mixed solution (ex, Roslyn files + HTML + JS + CSS), #2 still makes sense but #1 doesn't. We want to pause any work while something is going on in other project types as well.

we need to make sure we play nice with neighbors as well.

now, we don't care where changes are coming from. if there is any change in host, we puase oursevles for a while.
@heejaechang
Copy link
Contributor Author

@pharring @srivatsn @jasonmalinowski @rchande @shyamnamboodiripad can you take a look?

@heejaechang
Copy link
Contributor Author

by the way, this is an attempt to reduce allocation in one of perf tests.

@jasonmalinowski
Copy link
Member

Rather than couple all of this together, I'd feel better if there was a simple IWpfTextViewCreationListener that subscribed to events and then managed it's own state rather than tying this to the VS document provider. I think it'll be less code, would have the advantage that it'll work in non-VS hosts, and doesn't churn what is one of the more subtle pieces of code in our codebase.

foreach (var documentKey in documentsToClose)
// let others know about non roslyn document close
var buffer = TryGetTextBufferFromDocData(RunningDocumentTable.GetDocumentData(docCookie));
if (buffer != null)
Copy link
Member

Choose a reason for hiding this comment

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

What happens if the document, after already being open, was then added to the workspace? At this point this code path will get skipped, and the view unsubscribe might not run?

Trying to do this state tracking in this class really isn't the right thing to do. We should just have a separate class to subscribe to the text view notifications.

@heejaechang
Copy link
Contributor Author

@jasonmalinowski @pharring @rchande can you take a look?

@heejaechang
Copy link
Contributor Author

I talked to Jason already about using IWpfTextViewCreationListener. we can't use it due to several reasons. such as dll being loaded into VS even when Roslyn is not used or having circular reference unless we create new dll and etc.

private ITextView GetTextViewFromFrame(IVsWindowFrame frame)
{
IntPtr unknown;
if (ErrorHandler.Failed(frame.QueryViewInterface(typeof(IVsCodeWindow).GUID, out unknown)) || unknown == IntPtr.Zero)
Copy link
Contributor

Choose a reason for hiding this comment

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

This isn't the right way to get a code window from a frame. Microsoft.VisualStudio.Shell.VsShellUtilities has a GetTextView implementation which you should study. It deals with things such as split XAML/Designer views.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thank you

@pharring
Copy link
Contributor

pharring commented May 6, 2015

Please fix the GetTextView thing. Otherwise LGTM.

return;
}

view.TextBuffer.PostChanged -= OnTextChanged;
Copy link
Member

Choose a reason for hiding this comment

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

Don't forget to unsubscribe Closed as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

!!! thank you

@jasonmalinowski
Copy link
Member

👍 once Paul's comment is taken care of.

heejaechang added a commit that referenced this pull request May 7, 2015
track non roslyn text buffer changes as well as roslyn text buffer chang...
@heejaechang heejaechang merged commit 32524d5 into dotnet:master May 7, 2015
@pharring
Copy link
Contributor

pharring commented May 7, 2015

@heejaechang Why not call the MPF helper in your implementation of GetTextView?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants