summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <Michael.Stahl@cib.de>2019-05-02 18:27:07 +0200
committerMichael Stahl <Michael.Stahl@cib.de>2019-05-03 10:23:04 +0200
commitb69bc0facc6e0fbc2006125e656b82a7c2556203 (patch)
treedc390a83c53b9c67c3bf7a2b8b4be3b9adc8c5e9
parent40df8019ff3a8b1fd87b3e20e154fc487ab4a7db (diff)
tdf#123285 sw_redlinehide: fix SwAutoFormat::DelMoreLinesBlanks()
The "Delete spaces and tabs at end and start of line" AutoFormat option was deleting the wrong characters: on the 2nd line, it deletes the spaces as it should, but on subsequent lines the selection is off by the number of characters that have already been removed. The range indexes are now integers, so not automatically corrected on deletions like the SwIndex they were before; in this case, where only plain characters are deleted, it should suffice to iterate the ranges in reverse order to avoid the problem. (regression from 180e5f515c9cd21fb8057c797a480eca7d9ed260) Change-Id: Ie8e08c00803d94e700cd5b64f29edb0b841eda2b Reviewed-on: https://gerrit.libreoffice.org/71686 Tested-by: Jenkins Reviewed-by: Michael Stahl <Michael.Stahl@cib.de>
-rw-r--r--sw/source/core/edit/autofmt.cxx4
1 files changed, 3 insertions, 1 deletions
diff --git a/sw/source/core/edit/autofmt.cxx b/sw/source/core/edit/autofmt.cxx
index 740b3cc1f99b..36319230508d 100644
--- a/sw/source/core/edit/autofmt.cxx
+++ b/sw/source/core/edit/autofmt.cxx
@@ -1308,8 +1308,10 @@ void SwAutoFormat::DelMoreLinesBlanks( bool bWithLineBreaks )
std::vector<std::pair<TextFrameIndex, TextFrameIndex>> spaces;
aFInfo.GetSpaces(spaces, !m_aFlags.bAFormatByInput || bWithLineBreaks);
- for (auto & rSpaceRange : spaces)
+ // tdf#123285 iterate backwards - delete invalidates following indexes
+ for (auto iter = spaces.rbegin(); iter != spaces.rend(); ++iter)
{
+ auto & rSpaceRange(*iter);
assert(rSpaceRange.first != rSpaceRange.second);
bool const bHasBlanks = HasSelBlanks(
m_pCurTextFrame, rSpaceRange.first,