提交 327c639d 编写于 作者: C CyrusNajmabadi

Move option retrieval until later.

上级 3f628348
......@@ -90,9 +90,11 @@ public async Task<IList<TextChange>> GetFormattingChangesAsync(Document document
var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
var options = await document.GetOptionsAsync(cancellationToken).ConfigureAwait(false);
var span = textSpan.HasValue ? textSpan.Value : new TextSpan(0, root.FullSpan.Length);
var span = textSpan ?? new TextSpan(0, root.FullSpan.Length);
var formattingSpan = CommonFormattingHelpers.GetFormattingSpan(root, span);
return Formatter.GetFormattedTextChanges(root, new TextSpan[] { formattingSpan }, document.Project.Solution.Workspace, options, cancellationToken);
return Formatter.GetFormattedTextChanges(root,
SpecializedCollections.SingletonEnumerable(formattingSpan),
document.Project.Solution.Workspace, options, cancellationToken);
}
public async Task<IList<TextChange>> GetFormattingChangesOnPasteAsync(Document document, TextSpan textSpan, CancellationToken cancellationToken)
......@@ -201,8 +203,6 @@ private static bool TokenShouldNotFormatOnReturn(SyntaxToken token)
public async Task<IList<TextChange>> GetFormattingChangesAsync(Document document, char typedChar, int caretPosition, CancellationToken cancellationToken)
{
var options = await document.GetOptionsAsync(cancellationToken).ConfigureAwait(false);
var formattingRules = this.GetFormattingRules(document, caretPosition);
// first, find the token user just typed.
......@@ -228,6 +228,8 @@ public async Task<IList<TextChange>> GetFormattingChangesAsync(Document document
}
// don't attempt to format on close brace if autoformat on close brace feature is off, instead just smart indent
var options = await document.GetOptionsAsync(cancellationToken).ConfigureAwait(false);
var autoFormattingCloseBraceOff =
!options.GetOption(FeatureOnOffOptions.AutoFormattingOnCloseBrace) ||
!options.GetOption(FeatureOnOffOptions.AutoFormattingOnTyping);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册