Fixes #3964 https://gitlab.com/kicad/code/kicad/issues/3964
Part of https://gitlab.com/kicad/code/kicad/issues/3637