Allow modes to have default extensions other than "pde".

Aside from not crashing anymore, this patch changes mode-switch behavior as follows:
If you're in FooMode, and you're in an unmodified, empty sketch, the FooMode editor
is closed, and a BarMode editor is created. If you're in an unmodified, non-empty
sketch, it remains on-screen, and a new BarMode editor is created.

Fixes #2419 and #2420.