fix bug to not work fine for unsaved tab

fix #2