// the final space exept if I have a spanning inset or one string
// is so long that we force a break.
pos_type end = cur.textRow().endpos();
+ if (end == 0)
+ // empty text, end-1 is no valid position
+ return;
bool boundary = false;
- if (!cur.paragraph().isLineSeparator(end-1) &&
- !cur.paragraph().isNewline(end-1))
- {
- boundary = true;
- } else if (end != cur.lastpos())
- --end;
+ if (end != cur.lastpos()) {
+ if (!cur.paragraph().isLineSeparator(end-1)
+ && !cur.paragraph().isNewline(end-1))
+ boundary = true;
+ else
+ --end;
+ }
setCursor(cur, cur.pit(), end, true, boundary);
}
// needed to insert the selection
void LyXText::insertStringAsLines(LCursor & cur, string const & str)
{
- pit_type pit = cur.pit();
- pos_type pos = cur.pos();
- recordUndo(cur);
-
- // only to be sure, should not be neccessary
- cur.clearSelection();
- cur.buffer().insertStringAsLines(pars_, pit, pos, current_font, str,
- autoBreakRows_);
-
- cur.resetAnchor();
- setCursor(cur, cur.pit(), pos);
- cur.setSelection();
+ cur.buffer().insertStringAsLines(pars_, cur.pit(), cur.pos(),
+ current_font, str, autoBreakRows_);
}
#endif
x = int(tmpx) + xo;
- int const col = c - row.pos();
+ pos_type const col = c - row.pos();
if (!c || end == par.size())
return col;
if (cur.pos() != cur.lastpos()) {
bool updateNeeded = false;
if (!checkAndActivateInset(cur, true)) {
- if (cur.textRow().endpos() == (cur.pos() + 1) &&
+ if (cur.textRow().endpos() == cur.pos() + 1 &&
+ cur.textRow().endpos() != cur.lastpos() &&
!cur.paragraph().isLineSeparator(cur.pos()) &&
!cur.paragraph().isNewline(cur.pos()))
{
if (old.pos() > 0
&& old.pos() < oldpar.size()
&& oldpar.isLineSeparator(old.pos())
- && oldpar.isLineSeparator(old.pos() - 1)) {
+ && oldpar.isLineSeparator(old.pos() - 1)
+ && oldpar.lookupChange(old.pos() - 1) != Change::DELETED) {
// We need to set the text to Change::INSERTED to
// get it erased properly
pars_[old.pit()].setChange(old.pos() -1,