for ( size_t i = 0; i < lenNew; ++i, ++pos )
*pos = utf[i];
}
- else
+ else // length of character encoding in UTF-8 changed
{
// the worse case is when the new value has either longer or shorter
// code -- in that case, we have to use wxStringImpl::replace() and
// this invalidates all iterators, so we have to update them too:
- wxString& str = *wx_const_cast(wxString*, m_node.m_str);
- wxStringImpl& strimpl = str.m_impl;
+ wxStringImpl& strimpl = m_str.m_impl;
int iterDiff = lenNew - lenOld;
size_t posIdx = m_pos - strimpl.begin();
size_t *indexes = indexes_a;
size_t iterNum = 0;
wxStringIteratorNode *it;
- for ( it = str.m_iterators.ptr; it; it = it->m_next, ++iterNum )
+ for ( it = m_str.m_iterators.ptr; it; it = it->m_next, ++iterNum )
{
wxASSERT( it->m_iter || it->m_citer );
// update the string:
strimpl.replace(m_pos, m_pos + lenOld, utf, lenNew);
+#if wxUSE_STRING_POS_CACHE
+ m_str.InvalidateCache();
+#endif // wxUSE_STRING_POS_CACHE
+
// finally, set the iterators to valid values again (note that this
// updates m_pos as well):
size_t i;
- for ( i = 0, it = str.m_iterators.ptr; it; it = it->m_next, ++i )
+ for ( i = 0, it = m_str.m_iterators.ptr; it; it = it->m_next, ++i )
{
wxASSERT( i < iterNum );
wxASSERT( it->m_iter || it->m_citer );