Fixes https://gitlab.com/kicad/code/kicad/-/issues/2066 Also a partial fix for https://gitlab.com/kicad/code/kicad/-/issues/4577