-
Notifications
You must be signed in to change notification settings - Fork 33
Please add more documentation around ITextViewModelProvider #25
Comments
I filed a doc bug to improve the documentaiton. |
I am trying to create a custom editor that contains text from multiple text buffers. |
That's a standard scenario (cshtml, aspx, razor files use it) supported through projection: https://docs.microsoft.com/en-us/visualstudio/extensibility/inside-the-editor?view=vs-2019#projection, I don't think you need ITextViewModelProvider for that |
The page you mentioned talks about projection buffers from a "text buffer" perspective. How would one use such a buffer in an editor? |
VS "editor" is ITextView control over a single ITextBuffer representing document in a file. In projection case ITextBuffer is actually IProjectionBuffer, created via IProjectionBufferFactoryService.CreateProjectionBuffer and which represents more than one ITextBuffer projected into one. See also https://stackoverflow.com/a/37290780. Can you share more details about what are you trying to achieve? |
Given an ITextBuffer, how would you create a view? Is there a TextViewFactory that one can use? I was reading the following article: https://joshvarty.com/2014/08/01/ripping-the-visual-studio-editor-apart-with-projection-buffers/ Where ITextViewModelProvider is used, and I wanted to understand why it works. Regarding what I am trying to achieve, I want to hide certain text from an editor (CSharp ContenTtype) and also add text (just in the view, not the .cs files). If this is possible in the standard editor of VS then that is great. If not, I want to create a new editor window like the one in https://joshvarty.com/2014/08/01/ripping-the-visual-studio-editor-apart-with-projection-buffers/ I was able to do the later using ITextViewModelProvider, but I need to understand the code that I am writing and why it works. |
Yes, it's supported, that's how cshtml, aspx or razor files work - they project content from 2 files (e.g. aspx and generated cs files containing C# portion of aspx). |
And you create text view using ITextEditorFactoryService. |
Thanks @olegtk I want to replace some C# code with things like adornments. I did successfully replace these pieces of code with adornments but one issue is that you lose some VS features like IntelliSense and the squiggles in case of error or warning. I tried also successfully to create outlining to "replace" the C# code with other text. This has the nice feature of allowing the user to see the read code behind the "adornments". And if the user double clicks on an error in the error list VS automatically expands the outlining region and shows the error. Still not sure if this is a good option. The plus sign on the left is usually associated with real regions and it might confuse users. I am exploring all these options to figure out exactly how I am going to implement the requirement. I was exploring the option to create a new editor where I can add or remove code (via the projection buffer) and that's when ITextViewModelProvider came up. In general, I found the documentation of visual studio extensibility to be lacking. |
Sorry, still not entirely sure what are you trying to achieve... |
@olegtk , I, my self, am not sure what is the exact behavior that I need. In any case, there are only a finite amount of behaviors that can be achieved with Visual Studio extensibility. I am exploring different VS extensibility features and testing them and attempting to use them to see if they will help make the experience of devs who will use my product better. The product involves a lot of code generation and I would like to hide the names of some generated C# classes that the users have to put in their code. While doing such exploration, I came across ITextViewModelProvider and I think the documentation around it lacks. I think that the documentation of VS extensibility should be detailed enough to enable anyone to explore them and see how they can help them. I hope you agree. |
One piece of the puzzle is missing. How to connect custom created IProjectionBuffer with existing ITextView or how to connect custom created ITextView with existing VS Editor. ITextViewModelProvider gave such an opportunity, but it seems that it is not working since version 2019.3 of VS. I really would like to see a sample showing how to achieve something like cshtml/aspx with the help of IProjectionBuffer and without creating a custom editor. As I checked razor repository, they do not use IProjectionBuffer to achieve that result of mixing two languages in one view. |
It is not documented how an extension developer can create their own implementation of ITextViewModelProvider and how such implementation can be used by Visual Studio. Please add more details about this interface.
The text was updated successfully, but these errors were encountered: