parent
9fd5890e52
commit
edebdb5b29
|
|
@ -105,7 +105,7 @@ void RewriteBuffer::InsertText(unsigned OrigOffset,
|
||||||
unsigned RealOffset = getMappedOffset(OrigOffset, true);
|
unsigned RealOffset = getMappedOffset(OrigOffset, true);
|
||||||
assert(RealOffset <= Buffer.size() && "Invalid location");
|
assert(RealOffset <= Buffer.size() && "Invalid location");
|
||||||
|
|
||||||
// Remove the dead characters.
|
// Insert the new characters.
|
||||||
Buffer.insert(Buffer.begin()+RealOffset, StrData, StrData+StrLen);
|
Buffer.insert(Buffer.begin()+RealOffset, StrData, StrData+StrLen);
|
||||||
|
|
||||||
// Add a delta so that future changes are offset correctly.
|
// Add a delta so that future changes are offset correctly.
|
||||||
|
|
@ -121,8 +121,8 @@ void RewriteBuffer::ReplaceText(unsigned OrigOffset, unsigned OrigLength,
|
||||||
assert(RealOffset+OrigLength <= Buffer.size() && "Invalid location");
|
assert(RealOffset+OrigLength <= Buffer.size() && "Invalid location");
|
||||||
|
|
||||||
// Overwrite the common piece.
|
// Overwrite the common piece.
|
||||||
std::copy(NewStr, NewStr+std::min(OrigLength, NewLength),
|
unsigned CommonLength = std::min(OrigLength, NewLength);
|
||||||
Buffer.begin()+RealOffset);
|
std::copy(NewStr, NewStr+CommonLength, Buffer.begin()+RealOffset);
|
||||||
|
|
||||||
// If replacing without shifting around, just overwrite the text.
|
// If replacing without shifting around, just overwrite the text.
|
||||||
if (OrigLength == NewLength)
|
if (OrigLength == NewLength)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue