improvise-umi4: an editor opens on the value, not on its rounded Display
CellValue's Display writes a non-whole number {:.4}, and every editor seed
was that string, so i then Enter on an untouched 1.23456789 stored 1.2346,
in the TUI (pivot and records) and in the browser, which seeds from the
projected edit_text. CellValue::edit_text is now the one home of the seed:
the shortest decimal that reads back as the same f64 (non-finite values
take the core.md §16 token). display_value_in's two arms and
cell_display's records arm all go through it; the now-orphaned
GridLayout::resolve_display is removed.
Text that reads as a number (007) is exact in the seed but still
reclassified by typed(); filed as improvise-ixxx.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VdfEGXA7aJ6ftMsCc9PJze
This commit is contained in:
@@ -1200,3 +1200,35 @@ off the `## Data` line and off `serde_json` and requires them equal. A second
|
||||
home that happens to agree is harmless; one that drifts fails there, and
|
||||
re-copying the tokens into `format.rs` with one letter changed was injected to
|
||||
prove it does.
|
||||
|
||||
## 17. An editor opens on the value, not on its `Display` (improvise-umi4)
|
||||
|
||||
`CellValue`'s `Display` is a **screen** spelling: a non-whole number is written
|
||||
`{:.4}`, so `1.23456789` reads `1.2346`. Every editor seed used to be that
|
||||
string (`display_value_in`'s pivot arm through `get_cell().to_string()`, its
|
||||
records arm through `records_display`, and `project::cell_display`'s records
|
||||
arm spelling it again), so pressing `i` and then `Enter` with nothing typed
|
||||
stored `1.2346`. The screen looked the same before and after, which is what
|
||||
made it silent data loss rather than a visible bug. The browser seeds from the
|
||||
projected `CellDisplay::edit_text`, which came from the same call, so it had
|
||||
the same bug.
|
||||
|
||||
`CellValue::edit_text` is the one home of the seed. A number is written as the
|
||||
**shortest decimal that parses back to the same `f64`**, which is what Rust's
|
||||
`f64` `Display` already guarantees (no precision argument, no exponent). The
|
||||
brief pointed at improvise-gp's `number_text` as the implementation to reuse.
|
||||
It is not a second implementation of this one: it takes an `f32` and searches
|
||||
fixed precisions for the shortest *f64* expansion of it, because a threshold
|
||||
must route the same under f32 and f64 evaluation. For an `f64` the standard
|
||||
library's spelling is the same answer with no search. A non-finite number takes
|
||||
§16's token (`inf`, `-inf`, `nan`), which `typed()` also reads back, so the
|
||||
editor and the `.improv` format spell it one way.
|
||||
|
||||
Text and errors keep `Display`. Text is written unchanged, and an error cell has
|
||||
no edit text on the wire anyway. Display itself is untouched: the grid still
|
||||
rounds (gotcha 8), only the seed changed.
|
||||
|
||||
What this does **not** fix: a text cell whose text reads as a number. `"007"`
|
||||
seeds `"007"`, and `typed()` classifies that as `Number(7.0)`. The seed is
|
||||
exact, but the classifier has no way to know the cell was text. That is
|
||||
improvise-ixxx.
|
||||
|
||||
Reference in New Issue
Block a user