mirror of
https://github.com/storytold/gridcraft.git
synced 2026-11-09 20:09:57 -06:00
Engine: python.set keeps a cell's result only for the same code and return type
python.set kept the stored result whenever the code was unchanged, also when the call switched the return type between an Excel value and a Python object. The cell then showed a value and preview of the other type, and a save wrote the new type with that old cached value. The result is now kept only when both the code and the return type match; otherwise the cell is new code, which shows #BLOCKED! until it runs, and its old spill goes with its readers recalculated.
This commit is contained in:
@@ -68,8 +68,10 @@ fn set(s: &mut Session, p: &Json) -> Result<Json> {
|
||||
if header {
|
||||
return Err(EngineError::Other(format!("{} is a table header; Python cells can't go in a table's header row", at.a1())));
|
||||
}
|
||||
// Unchanged code keeps its result (and its value); new code has none until it runs.
|
||||
let keep = old.filter(|o| o.code == py.code);
|
||||
// Unchanged code with the same return type keeps its result (and its value); new code, or a
|
||||
// new return type, has none until it runs: a result of the other type would show a value and
|
||||
// preview that don't belong to the cell.
|
||||
let keep = old.filter(|o| o.code == py.code && o.object == py.object);
|
||||
let value = match &keep {
|
||||
Some(o) => {
|
||||
py.output = o.output.clone();
|
||||
|
||||
Reference in New Issue
Block a user