fixed some bugs

I've tried finding a way to show the history when it's longer than the terminal buffer, but failed.
Perhaps I should make one.