Fix some glitches in inset-select-all

Fix a crash reported in #7727. This happened because cur.pos() was reset before cur.pit(). In this case, cur.lastpos() will usually be wrong.

Fix bad behaviour when selecting at top level with several paragraphs.

Update documentation.
This commit is contained in:
Jean-Marc Lasgouttes 2014-11-14 10:10:29 +01:00
parent 95f9bafff2
commit 3cbdfa1762
3 changed files with 18 additions and 11 deletions

View File

@ -98,7 +98,7 @@ The LyX Team
\end_layout
\begin_layout Date
2014-10-23
2014-11-14
\end_layout
\begin_layout Section*
@ -2171,13 +2171,16 @@ Sample inset-modify note Note Comment
inset-select-all
\end_layout
\begin_layout Description
Action Selects all contents of an inset.
Action Select all contents of an inset.
\end_layout
\begin_layout Description
Notion There are 3 successive levels: select current cell, select all cells of inset, select the inset from outside (in the enclosing inset).
\end_layout
\begin_layout Description
Syntax inset-select-all
\end_layout
\begin_layout Description
Origin vfr, 22 Aug 2009
Origin vfr, 22 Aug 2009; lasgouttes 1 Nov 2014
\end_layout
\begin_layout Subsection*
@ -3047,7 +3050,7 @@ Origin Abdel, Dec 27 2007
section-select
\end_layout
\begin_layout Description
Action Selects the whole section.
Action Select the whole section.
\end_layout
\begin_layout Description
Notion The cursor should be in a section heading before calling this lfun.

View File

@ -1812,24 +1812,25 @@ void BufferView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
cur.setSelection(true);
cur.posForward();
} else if (cur.selBegin().idx() != cur.selEnd().idx()
|| (cur.selBegin().at_cell_begin()
|| (cur.depth() > 1
&& cur.selBegin().at_cell_begin()
&& cur.selEnd().at_cell_end())) {
// At least one complete cell is selected.
// Select all cells
cur.pos() = 0;
cur.idx() = 0;
cur.pos() = 0;
cur.resetAnchor();
cur.setSelection(true);
cur.idx() = cur.lastidx();
cur.pos() = cur.lastpos();
} else {
// select current cell
cur.pos() = 0;
cur.pit() = 0;
cur.pos() = 0;
cur.resetAnchor();
cur.setSelection(true);
cur.pos() = cur.lastpos();
cur.pit() = cur.lastpit();
cur.pos() = cur.lastpos();
}
dr.screenUpdate(Update::Force);
break;

View File

@ -1150,16 +1150,19 @@ void LyXAction::init()
/*!
* \var lyx::FuncCode lyx::LFUN_INSET_SELECT_ALL
* \li Action: Selects all contents of an inset.
* \li Action: Select all contents of an inset.
* \li Notion: There are 3 successive levels: select current cell,
* select all cells of inset, select the inset from outside
* (in the enclosing inset).
* \li Syntax: inset-select-all
* \li Origin: vfr, 22 Aug 2009
* \li Origin: vfr, 22 Aug 2009; lasgouttes 1 Nov 2014
* \endvar
*/
{ LFUN_INSET_SELECT_ALL, "inset-select-all", ReadOnly, Edit },
/*!
* \var lyx::FuncCode lyx::LFUN_SECTION_SELECT
* \li Action: Selects the whole section.
* \li Action: Select the whole section.
* \li Notion: The cursor should be in a section heading
before calling this lfun.
* \li Syntax: section-select