Skip to content

Commit

Permalink
Bug fix for getFromAndTo
Browse files Browse the repository at this point in the history
* Was returning a min or max that was outside the scope of the editor.
* Update custom folder after addressing this issue.
  • Loading branch information
goetzrrGit committed Dec 29, 2024
1 parent e6bfa13 commit 7bd509c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/utilities/codemirror/custom-folder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,10 @@ export function foldVariables(containerNode: SyntaxNode, state: EditorState): {

// Calculate the length of the directive (e.g. "@INPUT_PARAMETERS_BEGIN" or "@LOCALS_BEGIN")
const directiveLength = state
.sliceDoc(containerNode.from, containerNode.to - variablesNodes.length ? getFromAndTo([...variablesNodes]).from : 0)
.sliceDoc(
containerNode.from,
containerNode.to - (variablesNodes.length > 0 ? getFromAndTo([...variablesNodes]).from : 0),
)
.split('\n')[0].length;

// Calculate the start of the fold range after the directive
Expand Down
2 changes: 1 addition & 1 deletion src/utilities/sequence-editor/tree-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export function getFromAndTo(nodes: (SyntaxNode | null)[]): { from: number; to:
to: Math.max(acc.to, node.to),
};
},
{ from: Number.MAX_VALUE, to: Number.MIN_VALUE },
{ from: nodes[0]?.from ?? 0, to: nodes[0]?.to ?? 0 },
);
}

Expand Down

0 comments on commit 7bd509c

Please sign in to comment.