Fix bug when editing new buffer