Skip to content

Allow brace completion in comments #12741

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

Merged
merged 2 commits into from
Dec 8, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/services/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1725,7 +1725,7 @@ namespace ts {
const sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName);

// Check if in a context where we don't want to perform any insertion
if (isInString(sourceFile, position) || isInComment(sourceFile, position)) {
if (isInString(sourceFile, position)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This should only be the case for { not for all braces. IMO

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Doesn't work for <>. But why should it exclude () and []?

Copy link
Contributor

Choose a reason for hiding this comment

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

What does C# do?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

c# does no completions for any type of braces inside comments..

Copy link
Contributor Author

Choose a reason for hiding this comment

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

c# is smart, otherwise too outside comments, it only completes when brackets are placed in an expected location

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, Don't have a strong opinion either way..

return false;
}

Expand Down
6 changes: 3 additions & 3 deletions tests/cases/fourslash/commentBraceCompletionPosition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
//// }

goTo.marker('1');
verify.not.isValidBraceCompletionAtPosition('(');
verify.isValidBraceCompletionAtPosition('(');

goTo.marker('2');
verify.not.isValidBraceCompletionAtPosition('(');
verify.isValidBraceCompletionAtPosition('(');

goTo.marker('3');
verify.not.isValidBraceCompletionAtPosition('(');
verify.isValidBraceCompletionAtPosition('(');