Delen via


ProposedEdit Constructors

Definition

Overloads

ProposedEdit(SnapshotSpan, String)

Create a new ProposedEdit.span

ProposedEdit(SnapshotSpan, String, IReadOnlyList<Field>)

Create a new ProposedEdit.

ProposedEdit(SnapshotSpan, String, IReadOnlyList<Field>, Nullable<Int32>, Int32)

Create a new ProposedEdit.

ProposedEdit(SnapshotSpan, String)

Create a new ProposedEdit.span

public ProposedEdit (Microsoft.VisualStudio.Text.SnapshotSpan span, string replacementText);
new Microsoft.VisualStudio.Language.Proposals.ProposedEdit : Microsoft.VisualStudio.Text.SnapshotSpan * string -> Microsoft.VisualStudio.Language.Proposals.ProposedEdit
Public Sub New (span As SnapshotSpan, replacementText As String)

Parameters

replacementText
String

Remarks

Note that the experience around managing proposed edits in which span.Length == 0 will be quite a bit different than edits in which span.Length > 0 (e.g. pure insertions vs. edits that replace text). In particular, any user edit around a replacement will be treated as if the user has diverged from the proposal (whereas an attempt will be made to reconcile some user edits with a pure insertion).

Applies to

ProposedEdit(SnapshotSpan, String, IReadOnlyList<Field>)

Create a new ProposedEdit.

public ProposedEdit (Microsoft.VisualStudio.Text.SnapshotSpan span, string replacementText, System.Collections.Generic.IReadOnlyList<Microsoft.VisualStudio.Language.Proposals.Field>? fields);
new Microsoft.VisualStudio.Language.Proposals.ProposedEdit : Microsoft.VisualStudio.Text.SnapshotSpan * string * System.Collections.Generic.IReadOnlyList<Microsoft.VisualStudio.Language.Proposals.Field> -> Microsoft.VisualStudio.Language.Proposals.ProposedEdit
Public Sub New (span As SnapshotSpan, replacementText As String, fields As IReadOnlyList(Of Field))

Parameters

replacementText
String

Remarks

Note that the experience around managing proposed edits in which span.Length == 0 will be quite a bit different than edits in which span.Length > 0 (e.g. pure insertions vs. edits that replace text). In particular, any user edit around a replacement will be treated as if the user has diverged from the proposal (whereas some edits around an insertion will mutate the edit appropriately).

The spans in fields correspond to positions within replacementText. For example if replacementText is "for (int i = 0; (i < length); ++i)" and but you want to treat "length" as a field, you'd return a Field with a Span of [22, 28).

Applies to

ProposedEdit(SnapshotSpan, String, IReadOnlyList<Field>, Nullable<Int32>, Int32)

Create a new ProposedEdit.

public ProposedEdit (Microsoft.VisualStudio.Text.SnapshotSpan span, string replacementText, System.Collections.Generic.IReadOnlyList<Microsoft.VisualStudio.Language.Proposals.Field>? fields, int? finalCaretPosition, int finalCaretVirtualOffset);
new Microsoft.VisualStudio.Language.Proposals.ProposedEdit : Microsoft.VisualStudio.Text.SnapshotSpan * string * System.Collections.Generic.IReadOnlyList<Microsoft.VisualStudio.Language.Proposals.Field> * Nullable<int> * int -> Microsoft.VisualStudio.Language.Proposals.ProposedEdit
Public Sub New (span As SnapshotSpan, replacementText As String, fields As IReadOnlyList(Of Field), finalCaretPosition As Nullable(Of Integer), finalCaretVirtualOffset As Integer)

Parameters

replacementText
String
finalCaretPosition
Nullable<Int32>
finalCaretVirtualOffset
Int32

Remarks

Note that the experience around managing proposed edits in which span.Length == 0 will be quite a bit different than edits in which span.Length > 0 (e.g. pure insertions vs. edits that replace text). In particular, any user edit around a replacement will be treated as if the user has diverged from the proposal (whereas some edits around an insertion will mutate the edit appropriately).

The spans in fields correspond to positions within replacementText. For example if replacementText is "for (int i = 0; (i < length); ++i)" and but you want to treat "length" as a field, you'd return a Field with a Span of [22, 28).

finalCaretPosition corresponds to the "final" position of the caret after accepting the edit. For example, if the the replacement text is "if ()" and, after accepting the prediction, you want to place the caret between the parenthesis, you would set finalCaretPosition to 4.

If finalCaretPosition causes the caret to be positioned at the end of an ITextSnapshotLine, then FinalCaretVirtualOffset can be used to position the caret in virtual space.

If a ProposalBase has multiple ProposedEdits that each specify a non-null FinalCaretPosition, then the FinalCaretPosition from the last edit is used.

If none of the ProposedEdits specify a FinalCaretPosition, then the caret is only moved as a side-effect of the edits being applied.

Applies to