mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 18:08:10 +00:00
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.
This commit is contained in:
parent
ecd7dee5ea
commit
ba7e2113f3
@ -1731,7 +1731,10 @@ Font const & Paragraph::getFontSettings(BufferParams const & bparams,
|
|||||||
|
|
||||||
FontSpan Paragraph::fontSpan(pos_type pos) const
|
FontSpan Paragraph::fontSpan(pos_type pos) const
|
||||||
{
|
{
|
||||||
LBUFERR(pos < size());
|
LBUFERR(pos <= size());
|
||||||
|
|
||||||
|
if (pos == size())
|
||||||
|
return FontSpan(pos, pos);
|
||||||
|
|
||||||
pos_type start = 0;
|
pos_type start = 0;
|
||||||
FontList::const_iterator cit = d->fontlist_.begin();
|
FontList::const_iterator cit = d->fontlist_.begin();
|
||||||
|
@ -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 pos = row.pos();
|
||||||
pos_type const body_pos = par.beginOfBody();
|
pos_type const body_pos = par.beginOfBody();
|
||||||
bool const is_rtl = text_->isRTL(par);
|
bool const is_rtl = text_->isRTL(par);
|
||||||
|
bool need_new_row = false;
|
||||||
|
|
||||||
row.clear();
|
row.clear();
|
||||||
row.left_margin = leftMargin(max_width_, pit, pos);
|
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.
|
// the width available for the row.
|
||||||
int const width = max_width_ - row.right_margin;
|
int const width = max_width_ - row.right_margin;
|
||||||
|
|
||||||
if (pos >= end) {
|
|
||||||
row.endpos(end);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ParagraphList const & pars = text_->paragraphs();
|
ParagraphList const & pars = text_->paragraphs();
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
@ -829,6 +825,9 @@ void TextMetrics::breakRow(Row & row, int const right_margin, pit_type const pit
|
|||||||
pos_type i = pos;
|
pos_type i = pos;
|
||||||
FontIterator fi = FontIterator(*this, par, pit, pos);
|
FontIterator fi = FontIterator(*this, par, pit, pos);
|
||||||
do {
|
do {
|
||||||
|
// this can happen for an empty row after a newline
|
||||||
|
if (i >= end)
|
||||||
|
break;
|
||||||
char_type c = par.getChar(i);
|
char_type c = par.getChar(i);
|
||||||
// The most special cases are handled first.
|
// The most special cases are handled first.
|
||||||
if (par.isInset(i)) {
|
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.empty() && row.back().inset
|
||||||
&& row.back().inset->display())) {
|
&& row.back().inset->display())) {
|
||||||
row.right_boundary(true);
|
row.right_boundary(true);
|
||||||
|
need_new_row = par.isNewline(i);
|
||||||
++i;
|
++i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -898,7 +898,7 @@ void TextMetrics::breakRow(Row & row, int const right_margin, pit_type const pit
|
|||||||
row.endpos(i);
|
row.endpos(i);
|
||||||
|
|
||||||
// End of paragraph marker
|
// End of paragraph marker
|
||||||
if (lyxrc.paragraph_markers
|
if (lyxrc.paragraph_markers && !need_new_row
|
||||||
&& i == end && size_type(pit + 1) < pars.size()) {
|
&& i == end && size_type(pit + 1) < pars.size()) {
|
||||||
// add a virtual element for the end-of-paragraph
|
// add a virtual element for the end-of-paragraph
|
||||||
// marker; it is shown on screen, but does not exist
|
// marker; it is shown on screen, but does not exist
|
||||||
|
Loading…
Reference in New Issue
Block a user