Skip to content

Commit

Permalink
fix infinite recursion in subsheets
Browse files Browse the repository at this point in the history
  • Loading branch information
tomcl committed Feb 4, 2022
1 parent a8b9804 commit 6a5a05d
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/Renderer/UI/FileMenuView.fs
Original file line number Diff line number Diff line change
Expand Up @@ -896,16 +896,19 @@ let viewTopMenu model messagesFunc simulateButtonFunc dispatch =

let sTrees = getSheetTrees project

let rec subSheetsOf sh =
let rec subSheetsOf path sh =
match Map.tryFind sh sTrees with
| Some tree -> tree.SubSheets
| None -> []
|> List.collect (fun ssh -> ssh.Node :: subSheetsOf ssh.Node)
|> List.collect (fun ssh ->
match List.contains ssh.Node path with
| true -> []
| false -> ssh.Node :: subSheetsOf (ssh.Node :: path) ssh.Node)
|> List.distinct

let allSubSheets =
mapKeys sTrees
|> Seq.collect subSheetsOf
|> Seq.collect (subSheetsOf [])
|> Set
let isSubSheet sh = Set.contains sh allSubSheets

Expand Down

0 comments on commit 6a5a05d

Please sign in to comment.