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

Exception when inserting completion item in empty editor #82

Closed
fabianoliver opened this issue Apr 1, 2017 · 0 comments
Closed

Exception when inserting completion item in empty editor #82

fabianoliver opened this issue Apr 1, 2017 · 0 comments

Comments

@fabianoliver
Copy link

fabianoliver commented Apr 1, 2017

Hi,

autocompletion seems to throw an exception when completing in an empty editor.

E.g. steps to reprodue:

Launch the editor, empty all code. Then type in something that will open the completion window, such as "us". Then delete contents again (e.g. backspace twice, or ctrl+a then delete). The editor will be empty, but the completion window will still be open.
Now, when picking anything from the completion window and insertnig it (tab), it'll crash in RoslynCompletionData.cs line 61, i.e. on

document.Replace(textChange.Span.Start, textChange.Span.Length,  new StringTextSource(textChange.NewText));

with System.Argument.OutOfRangeException: "0 <= length, offset(0) + length <= 0".

EDIT I've just noticed this doesn't only happen when the editor is empty, but also apparently in any circumstances where I assume there shouldn't be any completion, but the completion window is still open.
For example, it'll also occur when typing

"public cl"

then deleting the "cl" (so remainder is "public ") and inserting any item.

  • Edit 2 * Might be fixed as below, though might be even better to just hide the autocompletion window in those circumstances
                var docLength = document.Text.Length;
                var spanEnd = textChange.Span.End;

                var length = Math.Min(docLength, spanEnd) - textChange.Span.Start;

                document.Replace(textChange.Span.Start, length,
                    new StringTextSource(textChange.NewText));
@aelij aelij closed this as completed in a25d9be Apr 19, 2017
@aelij aelij added this to the 0.12 milestone Aug 12, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants