From 21ff30cc380e341369b478ea26fa418d0ffe4cdb Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Mon, 28 Jan 2008 10:50:24 +0000 Subject: [PATCH] * src/Text.cpp (changeCase): do not set the selection if it was not already set. * src/Paragraph.cpp (changeCase): make sure to update the selection as needed. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22695 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/Paragraph.cpp | 9 +-------- src/Paragraph.h | 2 +- src/Text.cpp | 13 +++++++++---- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp index 4f4d9ff563..19a99cfe09 100644 --- a/src/Paragraph.cpp +++ b/src/Paragraph.cpp @@ -991,13 +991,6 @@ void Paragraph::Private::validate(LaTeXFeatures & features, // then the layouts features.useLayout(layout.name()); - if (!layout.requires().empty()) { - vector req = layout.requires(); - for (vector::const_iterator it = req.begin(); - it != req.end(); ++it) { - features.require(*it); - } - } // then the fonts fontlist_.validate(features); @@ -2543,7 +2536,7 @@ Inset const * Paragraph::getInset(pos_type pos) const void Paragraph::changeCase(BufferParams const & bparams, pos_type pos, - pos_type right, TextCase action) + pos_type & right, TextCase action) { // process sequences of modified characters; in change // tracking mode, this approach results in much better diff --git a/src/Paragraph.h b/src/Paragraph.h index 3b9d4be36f..04ce3f4fbc 100644 --- a/src/Paragraph.h +++ b/src/Paragraph.h @@ -350,7 +350,7 @@ public: /// void changeCase(BufferParams const & bparams, pos_type pos, - pos_type right, TextCase action); + pos_type & right, TextCase action); /// find \param str string inside Paragraph. /// \return true if the specified string is at the specified position diff --git a/src/Text.cpp b/src/Text.cpp index 7b697e6fbc..6e2ee99964 100644 --- a/src/Text.cpp +++ b/src/Text.cpp @@ -823,9 +823,11 @@ void Text::changeCase(Cursor & cur, TextCase action) CursorSlice from; CursorSlice to; + bool gotsel = false; if (cur.selection()) { from = cur.selBegin(); to = cur.selEnd(); + gotsel = true; } else { from = cur.top(); getWord(from, to, PARTIAL_WORD); @@ -850,10 +852,13 @@ void Text::changeCase(Cursor & cur, TextCase action) } // the selection may have changed due to logically-only deleted chars - setCursor(cur, begPit, begPos); - cur.resetAnchor(); - setCursor(cur, endPit, right); - cur.setSelection(); + if (gotsel) { + setCursor(cur, begPit, begPos); + cur.resetAnchor(); + setCursor(cur, endPit, right); + cur.setSelection(); + } else + setCursor(cur, endPit, right); cur.checkBufferStructure(); }