Posted 19 years ago
by Russell Mason

Hi
SyntaxEditor v3.1.0204 .net 2.0, Windows XP
I have a problem when combining a member list and snippets. Using the attached sample do the following:
1) Hit the enter key 4 times to create some blank lines
2) Type the letter 's' then hit the tab key to insert a snippet (inserts 'Test TestValue' with TestValue being a replaceable value)
3) Type the letters 'te' then Ctrl-Space to bring up an IntelliSense list (this selects the first item in the member list)
4) Hit the enter key to complete the word
5) Hit the enter key again to dismiss the snippet replacement highlighting
The cursor jumps to the start of the document.
Am I doing something wrong or is this a bug?
Thanks
Russell MasonSnippet file (sorry, doesn't format well):
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>Test</Title>
<Shortcut>S</Shortcut>
<Description></Description>
<Author></Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>testValue</ID>
<ToolTip>Test Value</ToolTip>
<Default>TestValue</Default>
</Literal>
</Declarations></Snippet>
</CodeSnippet>
</CodeSnippets>
SyntaxEditor v3.1.0204 .net 2.0, Windows XP
I have a problem when combining a member list and snippets. Using the attached sample do the following:
1) Hit the enter key 4 times to create some blank lines
2) Type the letter 's' then hit the tab key to insert a snippet (inserts 'Test TestValue' with TestValue being a replaceable value)
3) Type the letters 'te' then Ctrl-Space to bring up an IntelliSense list (this selects the first item in the member list)
4) Hit the enter key to complete the word
5) Hit the enter key again to dismiss the snippet replacement highlighting
The cursor jumps to the start of the document.
Am I doing something wrong or is this a bug?
Thanks
Russell Mason
namespace ActiproSnippetIntilliPrompt
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
syntaxEditor1.IntelliPrompt.MemberList.Add(new IntelliPromptMemberListItem("Test1", 0));
syntaxEditor1.IntelliPrompt.MemberList.Add(new IntelliPromptMemberListItem("Test2", 0));
syntaxEditor1.IntelliPrompt.MemberList.Add(new IntelliPromptMemberListItem("Test3", 0));
syntaxEditor1.IntelliPrompt.MemberList.Add(new IntelliPromptMemberListItem("Test4", 0));
syntaxEditor1.IntelliPrompt.MemberList.Add(new IntelliPromptMemberListItem("Test5", 0));
}
private void syntaxEditor1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyData == (Keys.Control | Keys.Space))
{
int offset = syntaxEditor1.Document.GetWordRange(syntaxEditor1.SelectedView.Selection.EndOffset - 1).Min;
int length = syntaxEditor1.SelectedView.Selection.EndOffset - offset;
syntaxEditor1.IntelliPrompt.MemberList.Show(offset, length);
}
}
private void syntaxEditor1_KeyTyping(object sender, KeyTypingEventArgs e)
{
if (e.KeyData == Keys.Tab)
{
int offset = syntaxEditor1.Document.GetWordRange(syntaxEditor1.SelectedView.Selection.EndOffset - 1).Min;
int length = syntaxEditor1.SelectedView.Selection.EndOffset - offset;
string previousWord = syntaxEditor1.Document.GetSubstring(offset, length);
CodeSnippetFolder snippetFolder = new CodeSnippetFolder("Test", ".");
CodeSnippet codeSnippet = snippetFolder.FindCodeSnippetWithShortcut(previousWord, false);
if (codeSnippet != null)
{
e.Cancel = true;
syntaxEditor1.IntelliPrompt.CodeSnippets.Activate(codeSnippet, offset, length);
}
}
}
}
}
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>Test</Title>
<Shortcut>S</Shortcut>
<Description></Description>
<Author></Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>testValue</ID>
<ToolTip>Test Value</ToolTip>
<Default>TestValue</Default>
</Literal>
</Declarations>
<![CDATA[Test $testValue$$end$]]>
</CodeSnippet>
</CodeSnippets>