Skip to content

Semantic Snippets - Fix how snippets appear in the completion list#63277

Merged
akhera99 merged 7 commits intodotnet:mainfrom
akhera99:snippets/fix_completionitem_look
Aug 10, 2022
Merged

Semantic Snippets - Fix how snippets appear in the completion list#63277
akhera99 merged 7 commits intodotnet:mainfrom
akhera99:snippets/fix_completionitem_look

Conversation

@akhera99
Copy link
Copy Markdown
Member

@akhera99 akhera99 commented Aug 9, 2022

Changed the description of the completion items to match that of VS Code.

Since the old snippets and new snippets now share the same display text, we show both but default to the old snippets to appear first in the list.

2022-08-09.13-08-35_Trim.mp4

@ghost ghost added the Area-IDE label Aug 9, 2022
@akhera99 akhera99 marked this pull request as ready for review August 9, 2022 18:08
@akhera99 akhera99 requested a review from a team as a code owner August 9, 2022 18:08
@akhera99 akhera99 requested a review from genlu August 9, 2022 18:09
@genlu
Copy link
Copy Markdown
Member

genlu commented Aug 9, 2022

Could you please add a gif/screenshot for the change? Thanks!

public override string SnippetIdentifier => "if";

public override string SnippetDisplayName => FeaturesResources.Insert_an_if_statement;
public override string SnippetDescription => FeaturesResources.if_statement;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

fwiw, I think it's OK to use "Insert an if-statement" as inline description.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I changed it so it would align with what VS Code says. There is an open question on whether or not the snippets will be discoverable/users will know what they do, so that extra description may help.

@mikadumont what do you think?

position: position,
snippetIdentifier: snippetData.SnippetIdentifier,
glyph: Glyph.Snippet,
inlineDescription: snippetData.Description,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Unrelated to this PR, but I think we should provide description for snippets (tooltips, not inline description)

Count++;
// Matching items should be rare, no need to use object pool for this.
_displayNameToItemsMap[entireDisplayText] = new List<CompletionItem>() { sameNamedItem, item };
_displayNameToItemsMap[entireDisplayText] = new List<CompletionItem>() { item, sameNamedItem };
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We probabaly don't want to rely on the implementation detail like this to determine the item order. Given the order is ultimatedly decided by SortText, consider using it to differentiate two items instead.

public class CSharpConsoleSnippetCompletionProviderTests : AbstractCSharpSnippetCompletionProviderTests
{
protected override string ItemToCommit => FeaturesResources.Write_to_the_console;
protected override string ItemToCommit => "cw";
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: consider making this a constant in the snippet provider and referece it in the tests.

@genlu
Copy link
Copy Markdown
Member

genlu commented Aug 9, 2022

Done with the pass.

Since this change would affect the aggregated completion list (like sorting, selection, etc.), we need to add end-to-end tests for validation.
See CSharpCompletionCommandHandlerTests

displayText: displayText,
displayTextSuffix: displayTextSuffix,
glyph: glyph,
sortText: snippetIdentifier + " ",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

pls add comment to explain this.

@akhera99 akhera99 enabled auto-merge August 10, 2022 20:07
@akhera99 akhera99 merged commit 622fc44 into dotnet:main Aug 10, 2022
@ghost ghost added this to the Next milestone Aug 10, 2022
@dibarbet dibarbet modified the milestones: Next, 17.4 P2 Sep 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants