Skip to content

Commit

Permalink
[se] Fix bug 61855 (#590)
Browse files Browse the repository at this point in the history
[se] Fix bug 61855
Co-authored-by: Dmitriy Orlov <[email protected]>
Co-committed-by: Dmitriy Orlov <[email protected]>
  • Loading branch information
DimitryOrlov authored and GoshaZotov committed Feb 10, 2025
1 parent 6a318af commit 5c3ecc4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
11 changes: 6 additions & 5 deletions cell/view/WorkbookView.js
Original file line number Diff line number Diff line change
Expand Up @@ -3244,16 +3244,17 @@
this.cellEditor.changeCellText(sArguments);

if (name) {

var res = new AscCommonExcel.CFunctionInfo(name);
let res = new AscCommonExcel.CFunctionInfo(name);
if (needChange) {
res.asc_setArguments(args);
}
res.argumentsResult = [];
var argCalc = ws.calculateWizardFormula(args[argNum], argType);
let argCalc = ws.calculateWizardFormula(args[argNum], argType);
res.argumentsResult[argNum] = argCalc.str;
if (argCalc.obj && argCalc.obj.type !== AscCommonExcel.cElementType.error) {
var funcCalc = ws.calculateWizardFormula(name + '(' + sArguments + ')');
//second condition: if we haven't received the formulaResult, calculate with those arguments that exist in the array
if ((argCalc.obj && argCalc.obj.type !== AscCommonExcel.cElementType.error) ||
(argCalc.obj === null && res && !res.functionResult && args && sArguments)) {
let funcCalc = ws.calculateWizardFormula(name + '(' + sArguments + ')');
res.functionResult = funcCalc.str;
if (funcCalc.obj && funcCalc.obj.type !== AscCommonExcel.cElementType.error) {
res.formulaResult = ws.calculateWizardFormula(this.cellEditor.getText().substring(1)).str;
Expand Down
11 changes: 11 additions & 0 deletions tests/cell/spreadsheet-calculation/SheetStructureTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -3337,6 +3337,17 @@ $(function () {
wb.dependencyFormulas._foreachDefName(function(defName) {
wb.dependencyFormulas.removeDefName(undefined, defName.name);
});

// for bug 61855
let insertArgsRes = api.wb.insertArgumentsInFormula(["1"], 0, 0, "SUM", true/*bEndInsertArg*/);
assert.strictEqual(insertArgsRes && insertArgsRes.functionResult, "1", "Calculation result for SUM function when insert first argument in formula");

insertArgsRes = api.wb.insertArgumentsInFormula(["1,2"], 1, 0, "SUM", true);
assert.strictEqual(insertArgsRes && insertArgsRes.functionResult, "3", "Calculation result for SUM function when insert second argument in formula");

insertArgsRes = api.wb.insertArgumentsInFormula(["1"], 1, 0, "SUM", true);
assert.strictEqual(insertArgsRes && insertArgsRes.functionResult, "1", "Calculation result for SUM function when delete second argument in formula");

});

QUnit.test('autoCompleteFormula', function (assert) {
Expand Down

0 comments on commit 5c3ecc4

Please sign in to comment.