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

No completion items are returned if invoking completion in an empty Razor document #10613

Closed
alexgav opened this issue Jul 12, 2024 · 0 comments · Fixed by #11344
Closed

No completion items are returned if invoking completion in an empty Razor document #10613

alexgav opened this issue Jul 12, 2024 · 0 comments · Fixed by #11344
Assignees

Comments

@alexgav
Copy link
Contributor

alexgav commented Jul 12, 2024

If you add an empty .razor or .cshtml file and try to invoke completion using Ctrl+Space or Ctrl+J, you get no results.

We should get HTML tags and tag helpers (and snippets)

If the document is completely empty (zero length, not even whitespace), the issue is that RazorHtmlWriter doesn't produce mapping spans for zero-length tokens, so position doesn't map to HTML. See https://github.com/dotnet/razor/blob/7b511df1710c54ab1a36ea5e422c7edd7bb29d20/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/RazorHtmlWriter.cs#L198C13-L198C35

Correct fix would be to produce a mapping span for zero-length token at least for the special case of a completely empty (zero-length) document. Modifying compiler is a bit risky though, so maybe there is a less impactful workaround.

Also a completely empty razor file is probably not that common in practice. I would say this is probably a lower priority bug, but something we should keep track of.

Also see #10610 for some discussion and a related fix.

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

Successfully merging a pull request may close this issue.

3 participants