Almost all unpleasantness in research* is due to the interference of the ego voice in your head. Worrying about whether you are smart / talented / erudite enough. Whether you deserve (on some existential level) to be doing what you are doing. Any shortcoming in a sentence you just wrote, any frustration with a sentence that took you too long to write, becomes evidence of unworthiness. No wonder people suffer writing block and chronic procrastination. Who wants to be subjected to that inner voice every day!
If I see a flaw in something I wrote yesterday, I think to myself: "oh, I used the same word twice in the same sentence, let me change that." Not: what a bad writer I am, I should just give this up.
For some, the answer is to have a lot of positive ego, but the kind of positive ego that cannot withstand criticism is really just a weak ego. Suppose I sat down and said: "I am a great writer. Everything I do is gold." Then noticing something wrong, or, worse, having someone else point it out, would be devastating. It is easy to oscillate between exaggerated positive ego and humbling negative ego. Suppose I thought every article I sent out was flawless, and editors thought differently. Then I would have to deal with crushing blows to my self-esteem every time.
Of course, sometimes I do have pleasant thoughts while writing, like: that sentence sounds good, or, I am really smart, or, so-and-so is going to like this article, or, I am getting a lot done today, or, "not many people in my field could have done this." I don't really know how to repress those thoughts. I just acknowledge them and move on in quiet confidence.
*The rest of the unpleasantness is having other obligations that prevent you from doing it, or poor working conditions that impose too high a cost.