Fix on_filetypes use case

Small typo prevented usage of on_filetypes altogether.
Correct a typo that had no effect
Create the window/buffer records on demand

This makes them more self-contained and robust.

Previously, a buffer build-up with a filetype change could trigger an
error because the window record hasn't been created at that point.