Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not treat [topoaa.mol1] as a module #177

Merged
merged 2 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

## @i-vresse/wb-core 3.2.3 - 2024-10-09

### Fixed

- Do not treat `[topoaa.mol1]` as a module

## @i-vresse/wb-core 3.2.2 - 2024-10-09

### Added
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@i-vresse/wb-core",
"version": "3.2.2",
"version": "3.2.3",
"description": "React components to construct a workflow builder application",
"keywords": [
"react",
Expand Down
17 changes: 17 additions & 0 deletions packages/core/src/toml.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1112,4 +1112,21 @@ describe('lines2node()', () => {
const expected = [-1, -1, -1, -1, -1, 0, 0, 1]
expect(lookup).toEqual(expected)
})

it('given 2 sections', () => {
const workflow = [
'',
'molecules = [',
']',
'',
'[section1]',
'',
'[section1.mol1]'
].join('\n')

const lookup = lines2node(workflow)

const expected = [-1, -1, -1, -1, -1, 0, 0, 0]
expect(lookup).toEqual(expected)
})
})
5 changes: 3 additions & 2 deletions packages/core/src/toml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,8 @@ export function dedupWorkflow (inp: string): string {
* For each line in the text, return the node index.
* -1 for global parameters.
*
* Ignores table with dots in the name.
*
* @param text The TOML text
* @returns
*/
Expand All @@ -317,10 +319,9 @@ export function lines2node (text: string): number[] {
// highlighter linenumber starts with 1 so add offset
const nodeLines: number[] = [-1]
let nodeIndex = -1
const isTable = /^\[/
for (let i = 0; i < lines.length; i++) {
const line = lines[i]
if (isTable.test(line)) {
if (line.startsWith('[') && !line.includes('.')) {
nodeIndex++
}
nodeLines.push(nodeIndex)
Expand Down
Loading