* src/CutAndPaste.C:

* src/paragraph.C:
* src/paragraph.h:
* src/text2.C: consider change tracking in stripLeadingSpaces()

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@16684 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Michael Schmitt 2007-01-14 18:27:27 +00:00
parent 9c09f34da0
commit ee5aa68acf
4 changed files with 15 additions and 12 deletions

View File

@ -270,7 +270,7 @@ pasteSelectionHelper(LCursor & cur, ParagraphList const & parlist,
pars[last_paste].makeSameLayout(pars[last_paste + 1]); pars[last_paste].makeSameLayout(pars[last_paste + 1]);
mergeParagraph(buffer.params(), pars, last_paste); mergeParagraph(buffer.params(), pars, last_paste);
} else { } else {
pars[last_paste + 1].stripLeadingSpaces(); pars[last_paste + 1].stripLeadingSpaces(buffer.params().trackChanges);
++last_paste; ++last_paste;
} }
} }
@ -309,7 +309,7 @@ PitPosPair eraseSelectionHelper(BufferParams const & params,
(pit + 1 != endpit || pars[pit].hasSameLayout(pars[pit + 1]))) { (pit + 1 != endpit || pars[pit].hasSameLayout(pars[pit + 1]))) {
pos_type const thissize = pars[pit].size(); pos_type const thissize = pars[pit].size();
if (doclear) if (doclear)
pars[pit + 1].stripLeadingSpaces(); pars[pit + 1].stripLeadingSpaces(params.trackChanges);
mergeParagraph(params, pars, pit); mergeParagraph(params, pars, pit);
--endpit; --endpit;
if (pit == endpit) if (pit == endpit)
@ -539,7 +539,7 @@ void cutSelection(LCursor & cur, bool doclear, bool realcut)
// sometimes necessary // sometimes necessary
if (doclear) if (doclear)
text->paragraphs()[begpit].stripLeadingSpaces(); text->paragraphs()[begpit].stripLeadingSpaces(bp.trackChanges);
// cutSelection can invalidate the cursor so we need to set // cutSelection can invalidate the cursor so we need to set
// it anew. (Lgb) // it anew. (Lgb)

View File

@ -560,19 +560,22 @@ void Paragraph::makeSameLayout(Paragraph const & par)
} }
int Paragraph::stripLeadingSpaces() int Paragraph::stripLeadingSpaces(bool trackChanges)
{ {
if (isFreeSpacing()) if (isFreeSpacing())
return 0; return 0;
int i = 0; int pos = 0;
while (!empty() && (isNewline(0) || isLineSeparator(0)) int count = 0;
&& !isDeleted(0)) {
eraseChar(0, false); // no change tracking here while (pos < size() && (isNewline(pos) || isLineSeparator(pos))) {
++i; if (eraseChar(pos, trackChanges))
++count;
else
++pos;
} }
return i; return count;
} }

View File

@ -346,7 +346,7 @@ public:
int getPositionOfInset(InsetBase const * inset) const; int getPositionOfInset(InsetBase const * inset) const;
/// Returns the number of line breaks and white-space stripped at the start /// Returns the number of line breaks and white-space stripped at the start
int stripLeadingSpaces(); int stripLeadingSpaces(bool trackChanges);
/// return true if we allow multiple spaces /// return true if we allow multiple spaces
bool isFreeSpacing() const; bool isFreeSpacing() const;

View File

@ -1231,7 +1231,7 @@ bool LyXText::deleteEmptyParagraphMechanism(LCursor & cur,
return true; return true;
} }
if (oldpar.stripLeadingSpaces()) if (oldpar.stripLeadingSpaces(cur.buffer().params().trackChanges))
need_anchor_change = true; need_anchor_change = true;
return false; return false;