提交 612d1ee3 编写于 作者: C CyrusNajmabadi

Add comments.

上级 63f6dad6
......@@ -141,11 +141,17 @@ private static bool TokenShouldNotFormatOnReturn(SyntaxToken token)
private static async Task<bool> TokenShouldNotFormatOnTypeCharAsync(
SyntaxToken token, CancellationToken cancellationToken)
{
// If the token is a ) we only want to format if it's the close paren
// of a using statement. That way if we have nested usings, the inner
// using will align with the outer one when the user types the close paren.
if (token.IsKind(SyntaxKind.CloseParenToken) && !token.Parent.IsKind(SyntaxKind.UsingStatement))
{
return true;
}
// If the token is a : we only want to format if it's a labeled statement
// or case. When the colon is typed we'll want ot immediately have those
// statements snap to their appropriate indentation level.
if (token.IsKind(SyntaxKind.ColonToken) && !(token.Parent.IsKind(SyntaxKind.LabeledStatement) || token.Parent is SwitchLabelSyntax))
{
return true;
......@@ -185,9 +191,6 @@ public async Task<IList<TextChange>> GetFormattingChangesAsync(Document document
return null;
}
// Check to see if any of the below. If not, bail.
// case 1: The token is ')' and the parent is an using statement.
// case 2: The token is ':' and the parent is either labelled statement or case switch or default switch
var shouldNotFormat = await TokenShouldNotFormatOnTypeCharAsync(token, cancellationToken).ConfigureAwait(false);
if (shouldNotFormat)
{
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册