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?

4

3 回答 3

4

我不确定您使用的是什么语言,但在您的Exec方法中,听起来您正在执行类似 (c#) 的操作:

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

这里的原因是_被认为是标点符号,所以char.IsPunctuation(typedChar)返回 true,提交当前项目。

修复 - (char.IsPunctuation(typedChar) && typedChar != '_')

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

仅供参考:我已经通过调试这个扩展来测试这个 - https://github.com/kfmaurice/nla。如果没有此更改,它在键入下划线时也会提交。

于 2017-02-28T04:10:02.903 回答
2

如果您进入 Tools->Options->Text Editor->JavaScript->IntelliSense->References 应该有一个参考组的下拉列表(取决于您可能需要更改的项目类型)

一旦你有了正确的组,你会注意到有一些默认包含的智能感知参考文件。尝试删除 underscorefilter.js

在这里找到这个。让我知道这是否适合你。

于 2017-02-27T19:21:54.107 回答
2

Visual Studio使用了一系列插件,并且其他一些插件在您的插件之前处理下划线。尝试destructi6n的建议。

于 2017-02-28T07:28:40.343 回答