(cm, doc)
| 4821 | |
| 4822 | // Attach a document to an editor. |
| 4823 | function attachDoc(cm, doc) { |
| 4824 | if (doc.cm) { throw new Error("This document is already in use.") } |
| 4825 | cm.doc = doc; |
| 4826 | doc.cm = cm; |
| 4827 | estimateLineHeights(cm); |
| 4828 | loadMode(cm); |
| 4829 | setDirectionClass(cm); |
| 4830 | cm.options.direction = doc.direction; |
| 4831 | if (!cm.options.lineWrapping) { findMaxLine(cm); } |
| 4832 | cm.options.mode = doc.modeOption; |
| 4833 | regChange(cm); |
| 4834 | } |
| 4835 | |
| 4836 | function setDirectionClass(cm) { |
| 4837 | (cm.doc.direction == "rtl" ? addClass : rmClass)(cm.display.lineDiv, "CodeMirror-rtl"); |
no test coverage detected