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

The code completion effiencency can be improved #407

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

The code completion effiencency can be improved #407

xiaoxstz opened this issue Jul 25, 2023 · 0 comments

Comments

@xiaoxstz
Copy link

xiaoxstz commented Jul 25, 2023

In the project ICSharpCode.AvalonEdit.Sample, the code about code completion is shown below.

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);
		// provide AvalonEdit with the data:
		IList<ICompletionData> data = completionWindow.CompletionList.CompletionData;
		data.Add(new MyCompletionData("Item1"));
		data.Add(new MyCompletionData("Item2"));
		data.Add(new MyCompletionData("Item3"));
		data.Add(new MyCompletionData("Another item"));
		completionWindow.Show();
		completionWindow.Closed += delegate {
			completionWindow = null;
		};
	}
}

Every time before the completion window is used, it needs to be created. It wastes much computing force, especially when the CompletionData is large

So, I think there are two approaches below to improve.

  1. Create the completion window only one time. When it's needed, activated it.
  2. CompletionWindow.CompletionList.CompletionData should be writable for users. In this way, we can create the data only once. Every time the completion window is needed, we can pass the data to CompletionData.
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