If there's only one tab on an editor in VS Code, the default behavior is to close the editor right then and there.
Personally, and I think many others agree with me, this behavior is very annoying since the programmer would rather preserve the layout he or she created for the project's workspace.
How do I change this behavior?
I've found discussions on this topic, but all of the solutions do not seem to be the ideal one of simply leaving the editor open but empty. Most of them simply delete the related shortcuts, which seems to me like cutting your arm off just because you broke it.
Anyway, here are some useful links:
I think @VonC's answer almost had it. In the end, this other answer by @harrymc did it for me:
{
"key": "cmd+w",
"command": "-workbench.action.closeWindow",
"when": "!editorIsOpen && !multipleEditorGroups"
}