- // if we don't have a multicell selection...
- if (!cur.selIsMultiCell() ||
- // ...or we're not doing some LFUN_*_SELECT thing, anyway...
- (cmd.action != LFUN_CHAR_FORWARD_SELECT &&
- cmd.action != LFUN_CHAR_BACKWARD_SELECT &&
- cmd.action != LFUN_CHAR_RIGHT_SELECT &&
- cmd.action != LFUN_CHAR_LEFT_SELECT)) {
+ bool const select = cmd.action == LFUN_CHAR_FORWARD_SELECT ||
+ cmd.action == LFUN_CHAR_BACKWARD_SELECT ||
+ cmd.action == LFUN_CHAR_RIGHT_SELECT ||
+ cmd.action == LFUN_CHAR_LEFT_SELECT;
+
+ // If we have a multicell selection or we're
+ // not doing some LFUN_*_SELECT thing anyway...
+ if (!cur.selIsMultiCell() || !select) {
+ col_type const c = tabular.cellColumn(cur.idx());
+ row_type const r = tabular.cellRow(cur.idx());
+ // Are we trying to select the whole cell and is the whole cell
+ // not yet selected?
+ bool const select_whole = select && !isCellSelected(cur, r, c) &&
+ ((next_cell && cur.pit() == cur.lastpit()
+ && cur.pos() == cur.lastpos())
+ || (!next_cell && cur.pit() == 0 && cur.pos() == 0));
+