Do not try to put cursor after space if no space was kept

The logic was wrong and could cause crashes

Fixes bug #11777.
This commit is contained in:
Jean-Marc Lasgouttes 2020-04-13 12:58:43 +02:00
parent f293de29d9
commit cc5d3bd9f4
2 changed files with 4 additions and 1 deletions

View File

@ -797,8 +797,9 @@ void fixCursorAfterDelete(CursorSlice & cur, CursorSlice const & where,
return; return;
// If cursor position is after the deletion place update it // If cursor position is after the deletion place update it
// but if we are not at start of line keep it after the space that was kept.
if (cur.pos() > from) if (cur.pos() > from)
cur.pos() = max(from + 1, cur.pos() - num_chars); cur.pos() = max(from + (from > 0), cur.pos() - num_chars);
// Check also if we don't want to set the cursor on a spot behind the // Check also if we don't want to set the cursor on a spot behind the
// pagragraph because we erased the last character. // pagragraph because we erased the last character.

View File

@ -105,6 +105,8 @@ What's new
- Avoid crash in some cases where a dialog is shown during operation - Avoid crash in some cases where a dialog is shown during operation
(bug 11763). (bug 11763).
- Fix crash with nested insets when spaces are removed automatically (bug 11777).
* INTERNALS * INTERNALS