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

Fix completion at the start of readonly documents #33830

Merged
merged 1 commit into from Mar 8, 2019

Conversation

sharwell
Copy link
Member

@sharwell sharwell commented Mar 2, 2019

Fixes #33829

@sharwell sharwell removed the Blocked label Mar 3, 2019
@sharwell sharwell marked this pull request as ready for review March 3, 2019 20:24
@sharwell sharwell requested a review from a team as a code owner March 3, 2019 20:24
@@ -18,7 +18,7 @@ public override bool ShouldTriggerCompletion(SourceText text, int position, Comp
{
switch (trigger.Kind)
{
case CompletionTriggerKind.Insertion:
case CompletionTriggerKind.Insertion when position > 0:
var insertedCharacterPosition = position - 1;
return this.IsInsertionTrigger(text, insertedCharacterPosition, options);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it feels like we should have a normal unit test for this. I'm actually surprised we don't as i thought we explicitly tested a whole bunch of edge cases for completion.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will file a follow-up issue to add one.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the change. It seem that IsInsertionTrigger has checks for position > 0 as well but it is nice to have the check here earlier. Thank you!

The code works for both: old and new completions. So, the issue might occur from the very beginning. I would support it with a unit test now if we need to push it into 16.0.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason not to add a unit test now? Would this have also broken interactive entirely where you're regularly typing at the very start?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason not to add a unit test now?

I'm not sure where a unit test would go to hit this path, plus our existing test coverage of the feature is at least as good as what a unit test would provide.

Would this have also broken interactive entirely where you're regularly typing at the very start?

It only happens when you type a character to trigger completion, but something blocks that character from getting added to the IDE.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we used to have tests for this. @dpoeschl recall anywhere those might have been?

If it was a completion integration test covering this I wouldn't be too terribly worried, but I could easily imagine somebody falling into the "oh, this is just testing Edit and Continue" and not realize this is our only coverage for something like this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jasonmalinowski providing a unit test is not easy for the scenario. Here is my repro:

  1. Create a solution of two indenendent console applications.
  2. Do not build application 1
  3. Start debugging application 2 and stop at a break point
  4. Go to application 1 in editor and set cursor at position = 0
  5. Try to type anything.
  6. Get "Changes are not allowed if the project wan't built when debugging started"
  7. Hit Enter many times: once to close the dialog and the next one to attempt editing again (the cursor must be in the beginning of the file) , again and again.

I will file an issue to construct a unit test

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, but you don't need a debugger here right? Just create a editor read-only span across the buffer? It's only a few lines extra compared to a normal test...?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jasonmalinowski Yes, we do not need a debugger here. However, it is hard to reproduce the issue. I had to hit enter 20 times or so to get a NFW. I think we need a more elegant repro.

@ivanbasov
Copy link
Contributor

I think we should not expect to be called with position = 0 and reason = insertion. I have added an issue on Editor: https://devdiv.visualstudio.com/DevDiv/_workitems/edit/809690

@ivanbasov ivanbasov added the Tenet-Reliability Customer telemetry indicates that the product is failing in a crash/hang/dataloss manner. label Mar 5, 2019
@sharwell sharwell merged commit b6c6008 into dotnet:dev16.0-vs-deps Mar 8, 2019
@sharwell sharwell deleted the readonly-completion branch March 8, 2019 17:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Approved to merge Area-IDE Tenet-Reliability Customer telemetry indicates that the product is failing in a crash/hang/dataloss manner.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants