Stop intellisense session from closing prematurely
Asked Answered
M

3

10

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?

Monied answered 2/2, 2017 at 10:14 Comment(0)
D
4

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.

Demo answered 28/2, 2017 at 4:10 Comment(0)
M
2

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.

Monobasic answered 27/2, 2017 at 19:21 Comment(0)
U
2

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

Unbelief answered 28/2, 2017 at 7:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.