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

Omnisharp Syntax-Tree not updated with edits made during initial startup #1655

Open
ryanbrandenburg opened this issue Nov 21, 2019 · 6 comments

Comments

@ryanbrandenburg
Copy link

ryanbrandenburg commented Nov 21, 2019

Repro steps:

  1. Have an existing project with a Program.cs and any other *.cs file.
  2. Open the above project in VSCode with Omnisharp.
  3. Very quickly (before Omnisharp finishes loading), add the following method to the Program class: public static void Tester(){} and this function referencing it to your other class: public void Foo(){ Program.Tester(); }
  4. Wait until Omnisharp has completed first-time loading.
  5. Shift-Alt-F12 (Find-all-references) on the declaration of Tester and see that you get no results.
  6. Wait a significant amount of time (10-30 seconds should be enough) and try again. Still no results.
  7. Make any edit at all to the Program.cs class, then Shift-Alt-F12 again. See that it now finds the reference.

Expected behavior:

Changes made while Omnisharp is loading the initial document should still be processed and cause an update to the Syntax-tree, even if it's on a delay.

Actual behavior:

Changes made while Omnisharp is loading are "lost", only being "discovered" when another edit causes the Syntax-tree/semantic model to be re-evaluated.

CC @NTaylorMullen who I looked at this with.

@NTaylorMullen
Copy link
Contributor

/cc @JoeRobich

@bjorkstromm
Copy link
Member

Interesting. Do you save the file in Step 3?

If you enable trace log, can you see the UpdateBuffer request being sent to the server? If not, I think we should move this bug to Omnisharp-VSCode. A quick guess might be that server state is not running when document changes should be forwared to the server. https://github.com/OmniSharp/omnisharp-vscode/blob/8641dd47bf534298cf35bff9cd8c2d0431971367/src/features/changeForwarding.ts#L22

@ryanbrandenburg
Copy link
Author

The files don't get saved at any point. I don't know how to tell if an UpdateBuffer request was sent. I assume something containing that word would appear in the OmniSharp log? If that's the case then no such request is sent.

@bjorkstromm
Copy link
Member

I was able to reproduce, and can assure that no /updateBuffer request was received in the server during startup. These requests are lost, and probably due to the code I linked above. Once server had started and I started typing, then requests was sent.

Maybe VSCode Extension should buffer up the requests when server is in starting state? Or just send them as they'll be available in STDIN anyway, and will be read in correct order once server is initialized. See https://github.com/OmniSharp/omnisharp-roslyn/blob/master/src/OmniSharp.Stdio/Host.cs#L129

//cc @JoeRobich @filipw @david-driscoll

@nickspoons
Copy link
Member

"buffering up requests" is something we've done in OmniSharp-vim, but the problem is knowing when OmniSharp-roslyn is completely initialised and ready for the requests. See #1521

@SirIntruder
Copy link
Contributor

This reproduces for me only if I don't Ctrl+S the edited file during the loading process.

This leads me to believe the issue is that buffer requests were consumed by temporary "Misc" Document object omnisharp has created at edited file path (because it tried to find any project in solution including edited file path, but there are no projects in solution at this point). When Projects finish loading, they replace those temp Documents with permanent Document objects belonging to them, but since the new document objects load state from the File System, this doesn't include in-vscode edits done during the loading.

Since project load subroutine already looks up temporary documents in order to delete them when permanent objects arrive, loading up their src content or some variant of this may be a non-intrusive way of fixing this.

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

5 participants