diff --git a/src/Renderer/DrawBlock/BusWireUpdate.fs b/src/Renderer/DrawBlock/BusWireUpdate.fs index 11d000c02..9feb55cd0 100644 --- a/src/Renderer/DrawBlock/BusWireUpdate.fs +++ b/src/Renderer/DrawBlock/BusWireUpdate.fs @@ -1154,10 +1154,15 @@ let update (msg : Msg) (model : Model) : Model*Cmd = // reconstructed precisely /// check whether a laoded wires position matches a symbol vertex - let posMatchesVertex (pos:XYPos) (vertex: float*float) = - let epsilon = 0.00001 - abs (pos.X - (fst vertex)) < epsilon && - abs (pos.Y - (snd vertex)) < epsilon + /// If the vertices lits is empty the evrtex will be None, and not match + let posMatchesVertex (pos:XYPos) (vertexOpt: (float*float) option) = + match vertexOpt with + | None -> + false + | Some vertex -> + let epsilon = 0.00001 + abs (pos.X - (fst vertex)) < epsilon && + abs (pos.Y - (snd vertex)) < epsilon // get the newly loaded wires let newWires = @@ -1173,11 +1178,11 @@ let update (msg : Msg) (model : Model) : Model*Cmd = | true -> posMatchesVertex (Symbol.getInputPortLocation None model.Symbol inputId) - (List.last conn.Vertices |> getVertex) + (List.tryLast conn.Vertices |> Option.map getVertex) | false -> posMatchesVertex (Symbol.getOutputPortLocation None model.Symbol outputId) - (List.head conn.Vertices |> getVertex) + (List.tryHead conn.Vertices |> Option.map getVertex) |> (fun b -> if b then wire diff --git a/src/Renderer/Interface/FilesIO.fs b/src/Renderer/Interface/FilesIO.fs index 8036d5293..777f04cab 100644 --- a/src/Renderer/Interface/FilesIO.fs +++ b/src/Renderer/Interface/FilesIO.fs @@ -364,7 +364,6 @@ let readMemLines (addressWidth:int) (wordWidth: int) (lines: string array) = match Array.tryFind (function | Error _ -> true | _ -> false) parse with | None -> let defs = (Array.map (function |Ok x -> x | _ -> failwithf "What?") parse) - Array.iter (fun (a,b) -> printfn "a=%d, b=%d" a b) defs let repeats = Array.groupBy fst defs |> Array.filter (fun (num, vals) -> vals.Length > 1) @@ -383,8 +382,8 @@ let readMemDefns (addressWidth:int) (wordWidth: int) (fPath: string) = printfn "starting defn read" tryReadFileSync fPath |> Result.bind ( - (fun contents -> printfn "read file:\n contents={contents}"; contents) - >> String.splitRemoveEmptyEntries [|'\n';'\r'|] + //(fun contents -> printfn "read file:\n contents={contents}"; contents) + String.splitRemoveEmptyEntries [|'\n';'\r'|] >> readMemLines addressWidth wordWidth >> (fun x -> printfn "read lines"; x) >> Result.map Map.ofArray)