OpenCircuits / OpenCircuits

A free, open source, online digital circuit/logic designer.
https://www.opencircuits.io/
GNU General Public License v3.0
307 stars 75 forks source link

Snip WirePort Bug #985

Open vhada7 opened 2 years ago

vhada7 commented 2 years ago

Describe the bug Currently you can connect more than one wire to a WirePort but if you try to snip the port that is connected to those wires you will receive an error message: "Cannot create snip action with WirePort of >2 wires!". The snip actions only works if there are only two wires connected.

To Reproduce Steps to reproduce the behavior: 1.) In the image there are two examples, one with three wires connected and one with four wires connected to a single WirePort. image 2.) After highlighting the WirePort and pressing 'x' on the keyboard to snip the port you should receive this error. image image

Expected behavior One Potential Fix: Have the wires reconnect to the port behind the snipped port

Desktop:

LeonMontealegre commented 2 years ago

So I think the actual fix here would be the following: Screen Shot 2022-02-11 at 2 26 14 PM to Screen Shot 2022-02-11 at 2 26 22 PM

and then for a more complex case: Screen Shot 2022-02-11 at 2 27 07 PM to Screen Shot 2022-02-11 at 2 27 27 PM

or even

Screen Shot 2022-02-11 at 2 27 39 PM to Screen Shot 2022-02-11 at 2 27 55 PM

Whoever tackles this, please make sure to write some unit tests for these cases! Even better, start with writing the tests and then start fixing the issue!

TGCrystal commented 2 years ago

CreateSnipGateAction in digital/actions/SnipGateActionFactory.ts may be expandable to do this. It currently is used with a BUFGate or a NOTGate, but I see no reason why it shouldn't/couldn't also work on a WirePort.