locked
VSPackage: Provisional Text Highlight RRS feed

  • Question

  • Hello, I am working on feature for Visual Studio 2010+ where I need to show provisional (planned) selection.

    I tried multiple ways using Markers, Taggers and ClassificationFormat and so on,
    but those markers do not work correctly for me when they include linebreaks.

    All what I need is to somehow show to user a transient block representing a new selection.
    But without changing of current selection as it is too slow on large blocks (10k+ lines of code).
    Selection also moves caret which is not wanted.

    Colleague pointed me to ITextView.ProvisionalTextHighlight property of type ITrackingSpan,
    but he also discovered the issue described below.

    I tried to use it as:

    var span = _buffer.CurrentSnapshot.CreateTrackingSpan(e.Pos, e.Length, SpanTrackingMode.EdgeExclusive);
    _textView.ProvisionalTextHighlight = span;

    It works perfectly, but a highlighted text is blinking in caret time interval.

    What would you suggest to use for selection preview in VS2010+ ?

    In other words, how do I show ITrackingSpan in same colors and form as editor selection does?

    Thanks in advance.







    Monday, October 20, 2014 6:34 PM

Answers

  • Hi Dusan,

    I'm not familiar with this, but this is a MSDN document talking about how to highlight the selected word and other same words in the text editor:

    Walkthrough: Highlighting Text

    Does it meet your requirement?

    It would be better if you can post more of your code here, or upload a sample project in OneDrive so that we can reproduce the problem easily.

    Thanks for your understanding.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, October 21, 2014 9:18 AM