As far as I see, CodeMirror uses an approach which forces direction. This is not truly bidi as in bidi, direction is (as per my understanding) to be detected and handled automatically.
This can be done using
dir="auto" html attribute on text containers (the
pre in CodeMirror case)
I have made a Firefox add-on called Add Bidi Support to somehow apply what I mean in pages (on headings and paragraphs). There are some screenshot of its impact on pages. Take a look.