[Bug]: copy+pasting a formula that includes number in exponential format fails with the error "There is no AST with such key in the cache"

Open
#1,288 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
typescript
Domain
backend

Research direction

Start by reproducing the failure with the provided HyperFormula setup, focusing on the hf.copy() and hf.paste() entry points for the formula =1.25e+5. Compare this path with copying the first three columns; done means the exponential-formula copy and paste complete without the AST cache error and preserve the expected value.

Written by the indexing model from the issue text.

Description

Bug Impact: Medium
Description

Attempting to copy+paste a formula that includes exponential notation (e.g. "=1.25e+5") results in the error:
There is no AST with such key in the cache

code to reproduce:

import HyperFormula from 'hyperformula';

const hf = HyperFormula.buildEmpty({
  licenseKey: 'gpl-v3',
});

const sheetName = hf.addSheet('main');
const sheetId = hf.getSheetId(sheetName);

// Arrange data

const tableData = [['100000', '1.25e+5', '=100000', '=1.25e+5']];

hf.setCellContents(
  {
    row: 0,
    col: 0,
    sheet: sheetId,
  },
  tableData
);

// Act - copying the first three columns works fine:

hf.copy({
  start: { sheet: sheetId, col: 0, row: 0 },
  end: { sheet: sheetId, col: 2, row: 0 },
});
hf.paste({ sheet: sheetId, col: 0, row: 1 });

const row1Values = hf.getRangeValues({
  start: { sheet: sheetId, col: 0, row: 1 },
  end: { sheet: sheetId, col: 2, row: 1 },
});
console.log({ row1Values }); // as expected, values are: [100000, 125000, 100000]

// Act - copying the last column gives the error:

hf.copy({
  start: { sheet: sheetId, col: 3, row: 0 },
  end: { sheet: sheetId, col: 3, row: 0 },
});
hf.paste({ sheet: sheetId, col: 3, row: 1 }); // results in: Error: There is no AST with such key in the cache
Video or screenshots

No response

Demo

https://stackblitz.com/edit/js-1prf9j?file=index.js,index.html

HyperFormula version

2.5.0

Your framework

No response

Your environment

Chrome 114

Dominant language
TypeScript
Stars
2.8k
Forks
171
Avg merge
1d 22h
Merged PRs (30d)
7

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from handsontable/hyperformula

All issues in handsontable/hyperformula

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.