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?
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.