共用方式為


Source.ReformatSpan(EditArray, TextSpan) Method

Definition

This method formats the given span using the given EditArray. The default behavior does nothing. So you need to override this method if you want formatting to work. An empty input span means reformat the entire document. You also need to turn on Preferences.EnableFormatSelection.

public:
 virtual void ReformatSpan(Microsoft::VisualStudio::Package::EditArray ^ mgr, Microsoft::VisualStudio::TextManager::Interop::TextSpan span);
public virtual void ReformatSpan (Microsoft.VisualStudio.Package.EditArray mgr, Microsoft.VisualStudio.TextManager.Interop.TextSpan span);
abstract member ReformatSpan : Microsoft.VisualStudio.Package.EditArray * Microsoft.VisualStudio.TextManager.Interop.TextSpan -> unit
override this.ReformatSpan : Microsoft.VisualStudio.Package.EditArray * Microsoft.VisualStudio.TextManager.Interop.TextSpan -> unit
Public Overridable Sub ReformatSpan (mgr As EditArray, span As TextSpan)

Parameters

mgr
EditArray

An EditArray object that contains the source to be reformatted.

span
TextSpan

A TextSpan object describing the range of lines to be reformatted.

Remarks

The EditArray object encapsulates all changes made as a single edit operation for the purposes of undo. So all changes made to the source file have to be given to the EditArray by calling the Add method with each line updated or with a single span encompassing the entire span being formatted.

This method is called when the user selects Format Selection or Format Document. This method is called only if the EnableFormatSelection property is true.

The base method does nothing.

In the default managed package framework implementation of the language service classes, this method is called from the ReformatSelection method and the ReformatDocument method in the ViewFilter class.

See Reformatting Code in a Legacy Language Service for examples of how this method can be implemented and used.

Applies to