Skip to content

Commit 9e19d3c

Browse files
committed
Merge branch 'pu/arrays' into pu/arrays2
2 parents 8ee1f08 + a0f8a29 commit 9e19d3c

19 files changed

Lines changed: 50 additions & 54 deletions

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2020
- Added ability to fallback to plain CPU implementation for functions that uses GPU.js (#355)
2121

2222
### Fixed
23+
- Fixed minor issue. (#631)
2324
- Fixed a bug with serialization of some addresses after CRUDs. (#587)
2425
- Fixed a bug with MEDIAN function implementation. (#601)
2526
- Fixed a bug with copy-paste operation that could cause out of scope references (#591)

‎src/Config.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,8 @@ export class Config implements ConfigParams, ParserConfig {
698698
}
699699

700700
if (duplicates.length > 0) {
701-
const paramNames = duplicates.map(entry => `[${entry.sort()}]`).join('; ')
701+
duplicates.forEach(entry => entry.sort())
702+
const paramNames = duplicates.map(entry => `[${entry}]`).join('; ')
702703
throw new Error(`Config initialization failed. Parameters in conflict: ${paramNames}`)
703704
}
704705
}

‎src/CrudOperations.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -619,9 +619,9 @@ export class CrudOperations {
619619
}
620620
}
621621

622-
public ensureItIsPossibleToChangeCellContents(address: SimpleCellAddress, content: RawCellContent[][]) {
622+
public ensureItIsPossibleToChangeCellContents(inputAddress: SimpleCellAddress, content: RawCellContent[][]) {
623623
const boundaries = findBoundaries(content)
624-
const targetRange = AbsoluteCellRange.spanFrom(address, boundaries.width, boundaries.height)
624+
const targetRange = AbsoluteCellRange.spanFrom(inputAddress, boundaries.width, boundaries.height)
625625
this.ensureRangeInSizeLimits(targetRange)
626626
for (const address of targetRange.addresses(this.dependencyGraph)) {
627627
this.ensureItIsPossibleToChangeContent(address)

‎src/DependencyGraph/DependencyGraph.ts‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,7 @@ export class DependencyGraph {
752752

753753
public dependencyQueryVertices: (vertex: Vertex) => Maybe<Vertex[]> = (vertex: Vertex) => {
754754
if (vertex instanceof RangeVertex) {
755-
return this.rangeDependencyQuery(vertex).map(([_, vertex]) => vertex)
755+
return this.rangeDependencyQuery(vertex).map(([_, v]) => v)
756756
} else {
757757
const dependenciesResult = this.formulaDependencyQuery(vertex)
758758
if (dependenciesResult !== undefined) {
@@ -959,8 +959,8 @@ export class DependencyGraph {
959959
})
960960
}
961961

962-
private removeVertexAndCleanupDependencies(vertex: Vertex) {
963-
const dependencies = new Set(this.graph.removeNode(vertex))
962+
private removeVertexAndCleanupDependencies(inputVertex: Vertex) {
963+
const dependencies = new Set(this.graph.removeNode(inputVertex))
964964
while (dependencies.size > 0) {
965965
const vertex: Vertex = dependencies.values().next().value
966966
dependencies.delete(vertex)
@@ -977,8 +977,8 @@ export class DependencyGraph {
977977
}
978978
}
979979

980-
public getAdjacentNodesAddresses(vertex: Vertex): (AbsoluteCellRange | SimpleCellAddress)[] {
981-
const deps = this.graph.adjacentNodes(vertex)
980+
public getAdjacentNodesAddresses(inputVertex: Vertex): (AbsoluteCellRange | SimpleCellAddress)[] {
981+
const deps = this.graph.adjacentNodes(inputVertex)
982982
const ret: (AbsoluteCellRange | SimpleCellAddress)[] = []
983983
deps.forEach((vertex: Vertex) => {
984984
const castVertex = vertex as RangeVertex | FormulaCellVertex | MatrixVertex

‎src/DependencyGraph/Graph.ts‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,8 @@ export class Graph<T> {
208208

209209
const sccNonSingletons: Set<T> = new Set()
210210

211-
modifiedNodes.reverse().forEach( (v: T) => {
211+
modifiedNodes.reverse()
212+
modifiedNodes.forEach( (v: T) => {
212213
if (nodeStatus.get(v) !== undefined) {
213214
return
214215
}
@@ -282,7 +283,8 @@ export class Graph<T> {
282283

283284
const sorted: T[] = []
284285
const cycled: T[] = []
285-
order.reverse().forEach( (t: T) => {
286+
order.reverse()
287+
order.forEach( (t: T) => {
286288
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
287289
if (sccNonSingletons.has(t) || this.adjacentNodes(t).has(t)) {
288290
cycled.push(t)

‎src/DependencyGraph/RangeMapping.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ export class RangeMapping {
8787
}
8888

8989
const verticesToMerge: [RangeVertex, RangeVertex][] = []
90-
for (const [oldKey, vertex] of updated.sort((left, right) => compareBy(left[1], right[1], coordinate))) {
90+
updated.sort((left, right) => compareBy(left[1], right[1], coordinate))
91+
for (const [oldKey, vertex] of updated) {
9192
const newKey = keyFromRange(vertex.range)
9293
if (newKey === oldKey) {
9394
continue

‎src/GraphBuilder.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,8 @@ export class MatrixDetectionStrategy implements GraphBuilderStrategy {
217217
const notMatrices = matrixHeuristic.run(sheets)
218218
for (let i = notMatrices.length - 1; i >= 0; --i) {
219219
const elem = notMatrices[i]
220-
for (const address of elem.cells.reverse()) {
220+
elem.cells.reverse()
221+
for (const address of elem.cells) {
221222
const value = sheets[this.dependencyGraph.getSheetName(address.sheet)][address.row][address.col]
222223
const vertex = new ValueCellVertex(Number(value), value)
223224
this.columnSearch.add(Number(value), address)

‎src/GraphBuilderMatrixHeuristic.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ import {Matrix, MatrixSize} from './Matrix'
1212
import {Sheets} from './Sheet'
1313

1414
export class Array2d<T> {
15-
public static fromArray<T>(input: T[][]): Array2d<T> {
15+
public static fromArray<U>(input: U[][]): Array2d<U> {
1616
const size: MatrixSize = new MatrixSize(input[0].length, input.length)
17-
const array = new Array2d<T>(size)
17+
const array = new Array2d<U>(size)
1818
for (let i = 0; i < size.height; ++i) {
1919
for (let j = 0; j < size.width; ++j) {
2020
array.set(j, i, input[i][j])

‎src/Matrix.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export function checkMatrixSize(ast: Ast, formulaAddress: SimpleCellAddress): Ma
4646
if (ast.args.length !== 2) {
4747
return new CellError(ErrorType.NA, ErrorMessage.WrongArgNumber)
4848
}
49-
if (ast.args.some((ast) => ast.type === AstNodeType.EMPTY)) {
49+
if (ast.args.some((astIt) => astIt.type === AstNodeType.EMPTY)) {
5050
return new CellError(ErrorType.NUM, ErrorMessage.EmptyArg )
5151
}
5252

@@ -68,7 +68,7 @@ export function checkMatrixSize(ast: Ast, formulaAddress: SimpleCellAddress): Ma
6868
if (ast.args.length < 2 || ast.args.length > 3) {
6969
return new CellError(ErrorType.NA, ErrorMessage.WrongArgNumber)
7070
}
71-
if (ast.args.some((ast) => ast.type === AstNodeType.EMPTY)) {
71+
if (ast.args.some((astIt) => astIt.type === AstNodeType.EMPTY)) {
7272
return new CellError(ErrorType.NUM, ErrorMessage.EmptyArg )
7373
}
7474

‎src/NamedExpressions.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,11 +200,11 @@ export class NamedExpressions {
200200
}
201201

202202
public namedExpressionOrPlaceholder(expressionName: string, sheetId: number): InternalNamedExpression {
203-
const namedExpression = this.worksheetStore(sheetId).get(expressionName)
203+
let namedExpression = this.worksheetStore(sheetId).get(expressionName)
204204
if (namedExpression) {
205205
return namedExpression
206206
} else {
207-
let namedExpression = this.workbookStore.get(expressionName)
207+
namedExpression = this.workbookStore.get(expressionName)
208208
if (namedExpression === undefined) {
209209
namedExpression = new InternalNamedExpression(expressionName, this.nextAddress(), false)
210210
this.workbookStore.add(namedExpression)

0 commit comments

Comments
 (0)