diff --git a/src/core/alphabet.js b/src/core/alphabet.js index a4df232c..a856ae07 100644 --- a/src/core/alphabet.js +++ b/src/core/alphabet.js @@ -80,9 +80,9 @@ export function xy2expr(x, y) { * @returns {tagA1} */ export function expr2expr(src, xn, yn, condition = () => true) { - if (xn === 0 && yn === 0) return src + if (xn === 0 && yn === 0) return src; const [x, y] = expr2xy(src); - if (!condition(x, y)) return src + if (!condition(x, y)) return src; return xy2expr(x + xn, y + yn); } diff --git a/src/core/row.js b/src/core/row.js index 33f44005..70de47ef 100644 --- a/src/core/row.js +++ b/src/core/row.js @@ -128,7 +128,6 @@ class Rows { if (deri < sri) dn = drn; else dn = dcn; } - // console.log('drn:', drn, ', dcn:', dcn, dn, isAdd); for (let i = sri; i <= eri; i += 1) { if (this._[i]) { for (let j = sci; j <= eci; j += 1) { @@ -157,7 +156,9 @@ class Rows { if (/^\d+$/.test(word)) return word; return expr2expr(word, xn, yn); }); - } else { + } else if ((rn <= 1 && cn > 1 && (dsri > eri || deri < sri)) + || (cn <= 1 && rn > 1 && (dsci > eci || deci < sci)) + || (rn <= 1 && cn <= 1)) { const result = /[\\.\d]+$/.exec(text); // console.log('result:', result); if (result !== null) { @@ -214,9 +215,9 @@ class Rows { nri += n; this.eachCells(ri, (ci, cell) => { if (cell.text && cell.text[0] === '=') { - cell.text = cell.text.replace(/\w{1,3}\d/g, (word) => expr2expr(word, 0, n, (x, y) => y >= sri)); + cell.text = cell.text.replace(/\w{1,3}\d/g, word => expr2expr(word, 0, n, (x, y) => y >= sri)); } - }) + }); } ndata[nri] = row; }); @@ -235,9 +236,9 @@ class Rows { ndata[nri - n] = row; this.eachCells(ri, (ci, cell) => { if (cell.text && cell.text[0] === '=') { - cell.text = cell.text.replace(/\w{1,3}\d/g, (word) => expr2expr(word, 0, -n, (x, y) => y > eri)); + cell.text = cell.text.replace(/\w{1,3}\d/g, word => expr2expr(word, 0, -n, (x, y) => y > eri)); } - }) + }); } }); this._ = ndata; @@ -252,7 +253,7 @@ class Rows { if (nci >= sci) { nci += n; if (cell.text && cell.text[0] === '=') { - cell.text = cell.text.replace(/\w{1,3}\d/g, (word) => expr2expr(word, n, 0, (x, y) => x >= sci)); + cell.text = cell.text.replace(/\w{1,3}\d/g, word => expr2expr(word, n, 0, x => x >= sci)); } } rndata[nci] = cell; @@ -272,7 +273,7 @@ class Rows { } else if (nci > eci) { rndata[nci - n] = cell; if (cell.text && cell.text[0] === '=') { - cell.text = cell.text.replace(/\w{1,3}\d/g, (word) => expr2expr(word, -n, 0, (x, y) => x > eci)); + cell.text = cell.text.replace(/\w{1,3}\d/g, word => expr2expr(word, -n, 0, x => x > eci)); } } });