Fix `editor.selectedContainer`

Can we make this a function and throw some tests specifically on it? This makes me nervous and it's not clear what it's doing.