TextEdit uses the default cocoa text widget. Both TextMate and Safari have reimplemented it. TextMate’s text widget is substantially more sophisticated, and Safari’s is mostly compatible except for a few annoying edge cases (it’s been a few years since I investigated; maybe some have been fixed).
Amusingly enough, Mail’s compose window uses WebKit for the content area. According to http://webkit.org/b/73888 the issue is specific to the WebKit2 layer that is currently used only by Safari.