Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I use the code completion by press Tab key other than input dot? #406

Open
xiaoxstz opened this issue Jul 25, 2023 · 0 comments
Open

Comments

@xiaoxstz
Copy link

xiaoxstz commented Jul 25, 2023

I have realized code completion according to the related document.

But I want the completion window to appear when I am typing, or after I press the Tab key.

My try

Delete if (e.Text == ".") of the original code.

void textEditor_TextArea_TextEntered(object sender, TextCompositionEventArgs e)
{
    if (e.Text == ".") {
        // Open code completion after the user has pressed dot:
        completionWindow = new CompletionWindow(textEditor.TextArea);
        IList<ICompletionData> data = completionWindow.CompletionList.CompletionData;
        data.Add(new MyCompletionData("Item1"));
        data.Add(new MyCompletionData("Item2"));
        data.Add(new MyCompletionData("Item3"));
        completionWindow.Show();
        completionWindow.Closed += delegate {
            completionWindow = null;
        };
    }
}

Then, the complete window will appear whatever I input. It's great!

However, if I input "It", and then choose "Item1" from the complete window. The content will turn to "IItem1"

An easy way to reproduce it

Download the source code of this repository, and then you can find the related code in Window1.xaml.cs of the project ICSharpCode.AvalonEdit.Sample

The original effect:
Run the project and then input “.” in the text editor

image

Try to realize "completion when typing"

Delete if (e.Text == ".") in the function textEditor_TextArea_TextEntered in Window1.xaml.cs

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant