Skip to content

Commit

Permalink
calc: fix: named-range can't be used in function like SUM
Browse files Browse the repository at this point in the history
Signed-off-by: Rashesh <[email protected]>
Change-Id: Ia07c579b3bc81ce73f40e86e6e07a02098e7bf4c
  • Loading branch information
Rash419 committed Aug 26, 2024
1 parent 209c3a4 commit 8d46119
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions browser/src/control/Control.FormulaAutoCompletePopup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,22 @@ class FormulaAutoCompletePopup extends L.Control.AutoCompletePopup {
if (eventType === 'close') {
this.closePopup();
} else if (eventType === 'select' || eventType === 'activate') {
var currentText = this.map._docLayer._lastFormula;
var chIndex = currentText.length - 1;
var functionName = this.functionList[index].name;
var namedRange = this.functionList[index].namedRange;
const namedRange: string = this.functionList[index].namedRange;
let currentText: string = this.map._docLayer._lastFormula;
if (namedRange) {
const openBracketIndex: number = currentText.indexOf('(');
const semicolonIndex: number = currentText.indexOf(';');
if (semicolonIndex !== -1) {
let tmpCurrentText = currentText.substring(semicolonIndex + 1);
// trim white space if there is any
tmpCurrentText = tmpCurrentText.trim();
currentText = ';' + tmpCurrentText;
} else if (openBracketIndex !== -1) {
currentText = currentText.substring(openBracketIndex);
}
}
const chIndex: number = currentText.length - 1;
let functionName: string = this.functionList[index].name;
functionName = functionName.substring(chIndex);
if (namedRange) this.map._textInput._sendText(functionName);
else this.map._textInput._sendText(functionName + '(');
Expand Down

0 comments on commit 8d46119

Please sign in to comment.