Show the selected range, not just the active cell, in status/formula bar
New store computed selectionRangeName: for a single cell it's identical
to activeCellName ("Umsatz::B2"), for a multi-cell selection it shows
the full primary rectangle ("Umsatz::B2:E6"), and a discontiguous
multi-selection gets a "+N" suffix for the further rectangles.
activeCellName itself is untouched (still anchor-only, since that's what
a formula/edit actually targets) -- only the formula bar's name field and
the status bar's range label switch to the new computed.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -138,6 +138,22 @@ describe('seed document acceptance (canvas model)', () => {
|
||||
// the active cell is the anchor -- the first cell of the selection -- not
|
||||
// wherever the selection was extended to.
|
||||
expect(s.activeCellName.value).toBe(`Umsatz::${toA1(1, 1)}`);
|
||||
// selectionRangeName shows the full range instead (status bar / formula bar)
|
||||
expect(s.selectionRangeName.value).toBe(`Umsatz::${toA1(1, 1)}:${toA1(1, 5)}`);
|
||||
});
|
||||
|
||||
it('selectionRangeName shows a single address for a 1x1 selection and a "+N" suffix for a discontiguous multi-selection', () => {
|
||||
const s = fresh();
|
||||
const umsatz = tableId(s, 'Umsatz');
|
||||
s.setSelection({ tableId: umsatz, anchor: { col: 0, row: 0 }, focus: { col: 0, row: 0 } });
|
||||
expect(s.selectionRangeName.value).toBe(`Umsatz::${toA1(0, 0)}`);
|
||||
|
||||
s.addToSelection(umsatz, 3, 3);
|
||||
s.addToSelection(umsatz, 5, 5);
|
||||
// addToSelection() moves the primary rect to the just-clicked cell (see
|
||||
// "Mehrfachauswahl" tests below) -- the range name follows it, plus a
|
||||
// "+N" for the other rectangles now in the selection.
|
||||
expect(s.selectionRangeName.value).toBe(`Umsatz::${toA1(5, 5)} +2`);
|
||||
});
|
||||
|
||||
it('recalculation visits precedents before dependents across tables', () => {
|
||||
|
||||
@@ -1412,6 +1412,28 @@ function createStore() {
|
||||
return `${t?.name ?? '—'}::${toA1(cell.col, cell.row)}`;
|
||||
});
|
||||
|
||||
/** Like {@link activeCellName}, but for a multi-cell selection it shows the
|
||||
* full range (`Umsatz::B2:E6`) instead of just the anchor -- used wherever
|
||||
* the UI shows "where am I" (formula bar, status bar), as opposed to
|
||||
* `activeCellName`/`activeCell`, which stay anchor-only because that's
|
||||
* what a formula/edit actually targets (see the "selection aggregate &
|
||||
* cell name are live" test). A discontiguous multi-selection additionally
|
||||
* gets a `+N` suffix for the further rectangles beyond the primary one. */
|
||||
const selectionRangeName = computed(() => {
|
||||
const sel = doc.selection;
|
||||
const t = sel ? tableById(sel.tableId) : activeTable.value;
|
||||
const tableName = t?.name ?? '—';
|
||||
if (!sel) return `${tableName}::${toA1(0, 0)}`;
|
||||
const rects = selectionRects(sel);
|
||||
const [p] = rects;
|
||||
const addr =
|
||||
p.c0 === p.c1 && p.r0 === p.r1
|
||||
? toA1(p.c0, p.r0)
|
||||
: `${toA1(p.c0, p.r0)}:${toA1(p.c1, p.r1)}`;
|
||||
const extra = rects.length > 1 ? ` +${rects.length - 1}` : '';
|
||||
return `${tableName}::${addr}${extra}`;
|
||||
});
|
||||
|
||||
const activeCellInput = computed(() => {
|
||||
const sel = doc.selection;
|
||||
return sel ? cellInput(sel.tableId, sel.anchor.col, sel.anchor.row) : '';
|
||||
@@ -1606,6 +1628,7 @@ function createStore() {
|
||||
selectionRects,
|
||||
activeCell,
|
||||
activeCellName,
|
||||
selectionRangeName,
|
||||
activeCellInput,
|
||||
selectionAggregate,
|
||||
// clipboard
|
||||
|
||||
Reference in New Issue
Block a user