Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9240641
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T08:13:30+00:00 2026-06-18T08:13:30+00:00

I am writing a Visual Studio extension which provides intelliSense for a certain content

  • 0

I am writing a Visual Studio extension which provides intelliSense for a certain content type.
The problem that I am facing now is the effect of “Auto Indent” that Visual Studio provides on empty lines when user types a character.

Here a completion session started on an empty line (over virtual spaces):

before

Notice the tab symbols on the other lines and no tab on the line with caret on it.

Now when use starts typing, VS automatically and correctly adds necessary tab characters to the line:

after

Now the problem is those Added tabs apparently become part of the user input and as a result CurrentSession.SelectedCompletionSet.SelectBestMatch() or Filter() method cannot find the current item which starts with “C” here (thinking user has typed \t\tC instead).

If I start the session on anywhere else which does not require auto indent everything works fine.

Any idea?

Edit (more information): I used a code flow very similar to:

  • Ook here
  • vsLua here
  • vsClojure here

In Lua and Clojure you wouldn’t face this problem because they never provide intelliSense on virtual spaces (meaning they always start after a certain set of characters) and if you start after a character virtual spaces are already turned into real spaces.

Ook on the other had has the same problem.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T08:13:31+00:00Added an answer on June 18, 2026 at 8:13 am

    Revised Answer:

    Ah, I see. I interpreted your question thinking that you were referring to completion triggering via typing, not from the explicit command. If you enable “show whitespace” for the C# editor, you can see what we do here: when you trigger the “show completion” command, we explicitly realize the whitespace so you’re no longer floating around in virtual space. You should probably do this as well. (Alternatively, you could detect the scenario and fix it up on the first typing by adjusting your ApplicableTo span, but that’s probably not worth the trouble.)

    You can get the whitespace that should be inserted from IEditorOperations. So MEF import an IEditorOperationsFactoryService, and then do:

    var editorOperations = editorOperationsFactoryService.GetEditorOperations(textView);
    var whitespace = editorOperations.GetWhitespaceForVirtualSpace(textView.Caret.Position.VirtualBufferPosition);
    if (whitespace.Length != 0)
    {
        textView.TextBuffer.Insert(textView.Caret.Position.BufferPosition, whitespace);
    }
    

    (Funny aside: as I answered this, I was curious to see how we handled this in the Roslyn C# and VB editors. The answer was “not”, but filtering still worked by pure luck later in the code.)

    Original Answer:

    I suspect by your description of the problem that you are implementing your completion like this: you know a character is about to be typed (either via a keyboard filter or IOleCommandTarget) and you trigger an ICompletionSession, where the tracking span is an empty span on the current caret position.

    The best approach to fixing this is to not trigger the session before the key is pressed and goes into the editor, but rather after it. This is what we do in the Roslyn implementation for C# and VB completion. Then, when you are in your AugmentCompletionSession call and creating your CompletionSet, compute the “applicable to” span which consists of the non-whitespace characters around your caret. The easiest way to compute this might just be to call GetWordExtent from the text structure navigator.

    This allows for other scenarios to work right. Consider scenarios where the user types C, presses escape, and then continues to type your identifier. If you want to trigger completion again, you’d have to do the math to ensure that the “C” is counted as part of your span anyways.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing a extension for visual studio, which will automatically generate some JS
I 'm writing a Visual Studio extension where I'm creating line adornments that need
I am writing a Visual Studio 2012 extension that defines several sub-menus to go
I'm writing an MPI program (Visual Studio 2k8 + MSMPI) that uses Boost::thread to
I'm writing an app in Visual Studio C++ and I have problem with assigning
I'm writing a small Win32 application in Visual Studio C/C++ that talks to a
I am writing a small program in Visual Studio 11 (beta) that a console
I'm writing a Visual Studio toolbar Add-In that displays the current time. I have
I writing a report in Visual Studio that takes a user input parameter and
I'm writing an XSL transform in Visual Studio. It is reporting that the semicolon

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.