commit ba7e2113f393c90776113ece5e7acad456f8e07c
Author: Jean-Marc Lasgouttes <[email protected]>
Date: Fri Mar 25 10:16:33 2016 +0100
Fix some display bugs related to end of paragraph markers
There are two regressions that are fixed here:
* empty rows at the end of a paragraph (think after newline at end of
paragraph or empty line in Verbatim) do not have an end-of-par
marker. This is fixed by removing the early return in breakRow and
letting the whole function be executed. This requires to relax an
assertion in Paragraph::fontSpan. It makes sense here to query
position at the end of the paragraph.
* a newline at the end of a paragraph will be followed by and
end-of-par marker. This is fixed by skipping the end-of-par marker
when a new row has been requested.
diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp
index 734d18a..9fe4de8 100644
--- a/src/Paragraph.cpp
+++ b/src/Paragraph.cpp
@@ -1731,7 +1731,10 @@ Font const & Paragraph::getFontSettings(BufferParams
const & bparams,
FontSpan Paragraph::fontSpan(pos_type pos) const
{
- LBUFERR(pos < size());
+ LBUFERR(pos <= size());
+
+ if (pos == size())
+ return FontSpan(pos, pos);
pos_type start = 0;
FontList::const_iterator cit = d->fontlist_.begin();
diff --git a/src/TextMetrics.cpp b/src/TextMetrics.cpp
index e930350..52af39a 100644
--- a/src/TextMetrics.cpp
+++ b/src/TextMetrics.cpp
@@ -791,6 +791,7 @@ void TextMetrics::breakRow(Row & row, int const
right_margin, pit_type const pit
pos_type const pos = row.pos();
pos_type const body_pos = par.beginOfBody();
bool const is_rtl = text_->isRTL(par);
+ bool need_new_row = false;
row.clear();
row.left_margin = leftMargin(max_width_, pit, pos);
@@ -803,11 +804,6 @@ void TextMetrics::breakRow(Row & row, int const
right_margin, pit_type const pit
// the width available for the row.
int const width = max_width_ - row.right_margin;
- if (pos >= end) {
- row.endpos(end);
- return;
- }
-
ParagraphList const & pars = text_->paragraphs();
#if 0
@@ -829,6 +825,9 @@ void TextMetrics::breakRow(Row & row, int const
right_margin, pit_type const pit
pos_type i = pos;
FontIterator fi = FontIterator(*this, par, pit, pos);
do {
+ // this can happen for an empty row after a newline
+ if (i >= end)
+ break;
char_type c = par.getChar(i);
// The most special cases are handled first.
if (par.isInset(i)) {
@@ -887,6 +886,7 @@ void TextMetrics::breakRow(Row & row, int const
right_margin, pit_type const pit
|| (!row.empty() && row.back().inset
&& row.back().inset->display())) {
row.right_boundary(true);
+ need_new_row = par.isNewline(i);
++i;
break;
}
@@ -898,7 +898,7 @@ void TextMetrics::breakRow(Row & row, int const
right_margin, pit_type const pit
row.endpos(i);
// End of paragraph marker
- if (lyxrc.paragraph_markers
+ if (lyxrc.paragraph_markers && !need_new_row
&& i == end && size_type(pit + 1) < pars.size()) {
// add a virtual element for the end-of-paragraph
// marker; it is shown on screen, but does not exist