In Paragraph::changeCase, correctly track the font of the changed characters (fix crash)

Fixes: #7943
This commit is contained in:
Juergen Spitzmueller 2014-03-24 09:15:00 +01:00 committed by Richard Heck
parent 892da302d6
commit 8b60088eaa
2 changed files with 9 additions and 5 deletions

View File

@ -3670,7 +3670,9 @@ void Paragraph::changeCase(BufferParams const & bparams, pos_type pos,
// process sequences of modified characters; in change // process sequences of modified characters; in change
// tracking mode, this approach results in much better // tracking mode, this approach results in much better
// usability than changing case on a char-by-char basis // usability than changing case on a char-by-char basis
docstring changes; // We also need to track the current font, since font
// changes within sequences can occur.
vector<pair<char_type, Font> > changes;
bool const trackChanges = bparams.trackChanges; bool const trackChanges = bparams.trackChanges;
@ -3704,7 +3706,7 @@ void Paragraph::changeCase(BufferParams const & bparams, pos_type pos,
} }
if (oldChar != newChar) { if (oldChar != newChar) {
changes += newChar; changes.push_back(make_pair(newChar, getFontSettings(bparams, pos)));
if (pos != right - 1) if (pos != right - 1)
continue; continue;
// step behind the changing area // step behind the changing area
@ -3713,9 +3715,8 @@ void Paragraph::changeCase(BufferParams const & bparams, pos_type pos,
int erasePos = pos - changes.size(); int erasePos = pos - changes.size();
for (size_t i = 0; i < changes.size(); i++) { for (size_t i = 0; i < changes.size(); i++) {
insertChar(pos, changes[i], insertChar(pos, changes[i].first,
getFontSettings(bparams, changes[i].second,
erasePos),
trackChanges); trackChanges);
if (!eraseChar(erasePos, trackChanges)) { if (!eraseChar(erasePos, trackChanges)) {
++erasePos; ++erasePos;

View File

@ -65,6 +65,9 @@ What's new
- Fix crash when CheckTeX hits mathed (bug 8798). - Fix crash when CheckTeX hits mathed (bug 8798).
- Fix crash when performing "Change Case" operation on a selection with font
changes (bug 7943).
- Fix assertion when entering a path into the import dialog (bug 7437). - Fix assertion when entering a path into the import dialog (bug 7437).
- Failed instant preview compilation now returns an error. And a red box is - Failed instant preview compilation now returns an error. And a red box is