Ask a questionAsk a question
 

Proposed AnswerTextBuffer for tooltips

  • Friday, August 14, 2009 4:17 PMMichael Feingold Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Has Code
    It appears that the Default QuickInfo presenter places the tooltip content into another text buffer, which goes through all classification/tagging and the such. As a result the format I want to display as a hint is colored as if in the code. I do not want it.

    Hence the question: how do I tell apart the tooltip buffer from the 'regular' one? The only way I found so far is this:
                // we do not need to mess with the text buffers for tooltips
                var formatMap = new VariableDescription();
                formatMap.Name = "FormatMap";
                var formatMapName = context.Get(formatMap);
                if (formatMapName.ToString() == "tooltip")
                    return false;
    
    
    but it seems really iffy. Any better ideas?

All Replies

  • Friday, October 23, 2009 7:29 AMNoah RichardsMSFTUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    What content type are you using for your extensions ("text")?

    "text" is the base type for lots of other types; in the case of quick info, the hierarchy is

    text -> intellisense -> quickinfo

    There are a few ways around this:

    1) Use a combination of "code" and "plaintext" on your components.
    2) In your providers, write something like:
        if (textBuffer.ContentType.IsOfType("intellisense"))
           return null;
    3) Same as #2, but if you want to provide components for some intellisense UI, then use "quickinfo" or whatever else you don't want specifically

    Let me know if that works!
    -Noah


  • Friday, October 23, 2009 3:52 PMMichael Feingold Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    I still need to figure this one out. In general django is a text generation engine, which can be used to generate anything. In reality it is primarily HTML and plain text as well as may be XML. It can also be JSON.
    I would love to be as precise about the editor as I can, i.e. I do not want my editor messing with .cs or .fs files. Can such selectivity be achieved through ContentType manipulation? What content type (s) should I use for this purpose?
    In the beginning I tried to introduce my own content type "django" it did not go too well, so I gave up and use "text" instead which of course causes excessive calls to the parser.
  • Monday, October 26, 2009 5:41 PMNoah RichardsMSFTUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Proposed Answer
    There are basically two ways to use [ContentType]:

    1) If you can enumerate all the content types you want (or if they fit into a category), use those types or that category for your [ContentType] attribute.
    2) If you can't, use the most specific category or categories that describe the content types you want, and then, in the provider's method, check for the content types you know you can't handle and ignore those.

    In your case, you could list out that you want "plaintext", "xml", etc. and then you won't need to ignore others (and you won't be called for C# and the like, which are text -> code -> C#).

    Thanks,
    -Noah