Share via


IVsTextStream.CanReplaceStream(Int32, Int32, Int32) Method

Definition

Tests whether a given editing operation can succeed (for example, copy or cut).

public:
 int CanReplaceStream(int iPos, int iOldLen, int iNewLen);
public:
 int CanReplaceStream(int iPos, int iOldLen, int iNewLen);
int CanReplaceStream(int iPos, int iOldLen, int iNewLen);
public int CanReplaceStream (int iPos, int iOldLen, int iNewLen);
abstract member CanReplaceStream : int * int * int -> int
Public Function CanReplaceStream (iPos As Integer, iOldLen As Integer, iNewLen As Integer) As Integer

Parameters

iPos
Int32

[in] Position in the text buffer.

iOldLen
Int32

[in] Length of text to replace, if any. In an insert operation, this value is zero (0).

iNewLen
Int32

[in] Length of the newly inserted text.

Returns

If the method succeeds, it returns S_OK. If it fails, it returns an error code.

Remarks

COM Signature

From textmgr.idl:

HRESULT IVsTextStream::CanReplaceStream(  
   [in] long iPos,  
   [in] long iOldLen,  
   [in] long iNewLen  
);  

In the text buffer, every change is modeled as a replace operation, regardless of whether text is inserted, replaced, or deleted within the line. As such, this method contains a starting position in the text buffer (iPos) and a length of text to replace (iOldLen). To test for an insert operation, set iOldLen to zero (0). To test whether text can be deleted, set iNewLen to zero (0) and then iOldLen would be greater than zero (0).

CanReplaceStream is used to test whether a given editing operation (for example, cut or copy) can succeed. Potential causes for failure include attempting to replace text in a read-only buffer (file is under source control), or attempting to replace text in a read-only region within the buffer.

Applies to