Reset the untitled document counter before changing projects
Refactor title shortening into _shortTitleForDocument helper