Skip to content

Commit

Permalink
related #316
Browse files Browse the repository at this point in the history
  • Loading branch information
myliang committed Jul 24, 2020
1 parent e21db10 commit 291a459
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/core/alphabet.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
17 changes: 9 additions & 8 deletions src/core/row.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
});
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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));
}
}
});
Expand Down

0 comments on commit 291a459

Please sign in to comment.