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 in an empty document #11344

Merged
merged 1 commit into from
Jan 2, 2025

Conversation

davidwengier
Copy link
Contributor

Fixes #10613
Fixes #10614

@davidwengier davidwengier requested a review from a team as a code owner January 2, 2025 00:50
// Special case for empty documents, to just force Html. When there is no content, then there are no source mappings,
// so the map call below fails, and we would default to Razor. This is fine for most cases, but empty documents are a
// special case where Html provides much better results when users first start typing.
return new DocumentPositionInfo(RazorLanguageKind.Html, new Position(0, 0), hostDocumentIndex);
Copy link
Contributor

@alexgav alexgav Jan 2, 2025

Choose a reason for hiding this comment

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

Thank you for the comment! :) #Resolved

TriggerCharacter = null,
TriggerKind = RoslynCompletionTriggerKind.Invoked
},
expectedItemLabels: ["snippet1", "snippet2"],
Copy link
Contributor

Choose a reason for hiding this comment

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

There is an unfortunate behavior change/regression in empty HTML document in HTML LSP editor. It no longer shows tags (as non-LSP editor and thus legacy Razor editor used to). E.g. legacy HTML

image

but no completion at all in LSP HTML editor (since there aren't any snippets). By extension that affects Razor as well.

Copy link
Contributor

Choose a reason for hiding this comment

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

No issues with changes in this PR though, thank you for fixing this case!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same conversation as #11343 (comment) really.

This PR isn't introducing any regression or change in behaviour. We don't show Html elements or components when completion is invoked on an empty line, as the completion items don't have the < in them, so they wouldn't produce valid code. This PR just makes the experience the same whether the document is empty or not.

@davidwengier davidwengier merged commit c068d47 into dotnet:main Jan 2, 2025
12 checks passed
@davidwengier davidwengier deleted the EmptyDocumentCompletion branch January 2, 2025 04:40
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Jan 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants