window: Replace the auto substitution mechanism by `Tab` substitution
window: Fix bug with `on_substitute` function