Stop intellisense session from closing prematurely

400 Views Asked by At

I've created a Visual Studio extension that provides intellisense for my domain specific language by inheriting from Microsoft.VisualStudio.Language.Intellisense.ICompletionSource.

This works ok, except that a valid character in the keywords of my language is underscore '_'.

When intellisense pops open you can start typing and the contents of the intellisense box is filtered to show just those items that start with what you've typed.

However, if the user types an underscore, that seems to be treated in a special way, instead of continuing to filter the list of available intellisense items, it commits the current item and ends the intellisense session.

Is there a way to stop this behaviour so that underscore can be treated the same as a regular alphanumeric characters?

3

There are 3 best solutions below

0
On BEST ANSWER

I'm not sure what language you're using, but in your Exec method it sounds like you're doing something like (c#):

if (nCmdID == (uint)VSConstants.VSStd2KCmdID.RETURN || nCmdID == (uint)VSConstants.VSStd2KCmdID.TAB || (char.IsWhiteSpace(typedChar) || char.IsPunctuation(typedChar))

The cause here is that _ is considered punctuation, so char.IsPunctuation(typedChar) returns true, committing the current item.

The fix - (char.IsPunctuation(typedChar) && typedChar != '_'):

if (nCmdID == (uint)VSConstants.VSStd2KCmdID.RETURN || nCmdID == (uint)VSConstants.VSStd2KCmdID.TAB || (char.IsWhiteSpace(typedChar) || (char.IsPunctuation(typedChar) && typedChar != '_') || typedChar == '='))

FYI: I've tested this by debugging this extension - https://github.com/kfmaurice/nla. Without this change it was also committing when typing an underscore.

0
On

If you go into Tools->Options->Text Editor->JavaScript->IntelliSense->References there should be a drop down for the reference group (depending on what type of project you may need to change this)

Once you have the right group you'll noticed there are some default included intellisense reference files. Try removing the underscorefilter.js

found this here. Let me know if that works for you.

0
On

There is chain of plugins used by visual studio, and some other plugin is processing underscore before your plugin. Try suggestion by destructi6n.