From 215476903e467c2d2839f3d697e74fd584ff67c5 Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Fri, 24 Feb 2006 12:58:31 +0000 Subject: [PATCH] fix bugs 2321 and 2323 git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@13272 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/ChangeLog | 11 +++++++++++ src/text.C | 10 ++++------ src/text3.C | 4 +++- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 29f5ad0f83..c554b0f3b6 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,14 @@ +2006-02-24 Jean-Marc Lasgouttes + + * text3.C (mathDispatch): fix crash when selection is not empty + but selectionAsString is empty (bug 2321). + +2006-02-23 Jean-Marc Lasgouttes + + * text.C (changeCase): avoid crash in empty paragraph or on last + word of the paragraph. (buf 2323) + (cursorRightOneWord): fix the logic to stop at a beginning of a word. + 2006-02-22 Jürgen Spitzmüller * buffer.C (readHeader): also erase params.preamble in advance diff --git a/src/text.C b/src/text.C index 96849d22e0..3e3c2afea3 100644 --- a/src/text.C +++ b/src/text.C @@ -1326,13 +1326,12 @@ bool LyXText::cursorRightOneWord(LCursor & cur) ++old.pit(); old.pos() = 0; } else { - // Skip through initial nonword stuff. - // Treat floats and insets as words. - while (old.pos() != old.lastpos() && !old.paragraph().isLetter(old.pos())) - ++old.pos(); // Advance through word. while (old.pos() != old.lastpos() && old.paragraph().isLetter(old.pos())) ++old.pos(); + // Skip through trailing nonword stuff. + while (old.pos() != old.lastpos() && !old.paragraph().isLetter(old.pos())) + ++old.pos(); } return setCursor(cur, old.pit(), old.pos()); } @@ -1349,7 +1348,6 @@ bool LyXText::cursorLeftOneWord(LCursor & cur) old.pos() = old.lastpos(); } else { // Skip through initial nonword stuff. - // Treat floats and insets as words. while (old.pos() != 0 && !old.paragraph().isLetter(old.pos() - 1)) --old.pos(); // Advance through word. @@ -1495,7 +1493,7 @@ void LyXText::changeCase(LCursor & cur, LyXText::TextCase action) } else { from = cur.top(); getWord(from, to, lyx::PARTIAL_WORD); - setCursor(cur, to.pit(), to.pos() + 1); + cursorRightOneWord(cur); } recordUndoSelection(cur); diff --git a/src/text3.C b/src/text3.C index 1dc903f7cf..e93a70b008 100644 --- a/src/text3.C +++ b/src/text3.C @@ -135,6 +135,9 @@ namespace { string sel = cur.selectionAsString(false); //lyxerr << "selection is: '" << sel << "'" << endl; + // It may happen that sel is empty but there is a selection + replaceSelection(cur); + if (sel.empty()) { const int old_pos = cur.pos(); cur.insert(new MathHullInset("simple")); @@ -155,7 +158,6 @@ namespace { // create a macro if we see "\\newcommand" // somewhere, and an ordinary formula // otherwise - cutSelection(cur, true, true); if (sel.find("\\newcommand") == string::npos && sel.find("\\def") == string::npos) { -- 2.39.2