| 1873 | // Work around nonsense dimensions being reported for stretches of |
| 1874 | // right-to-left text. |
| 1875 | function buildTokenBadBidi(inner, order) { |
| 1876 | return function (builder, text, style, startStyle, endStyle, css, attributes) { |
| 1877 | style = style ? style + " cm-force-border" : "cm-force-border"; |
| 1878 | var start = builder.pos, end = start + text.length; |
| 1879 | for (;;) { |
| 1880 | // Find the part that overlaps with the start of this text |
| 1881 | var part = (void 0); |
| 1882 | for (var i = 0; i < order.length; i++) { |
| 1883 | part = order[i]; |
| 1884 | if (part.to > start && part.from <= start) { break } |
| 1885 | } |
| 1886 | if (part.to >= end) { return inner(builder, text, style, startStyle, endStyle, css, attributes) } |
| 1887 | inner(builder, text.slice(0, part.to - start), style, startStyle, null, css, attributes); |
| 1888 | startStyle = null; |
| 1889 | text = text.slice(part.to - start); |
| 1890 | start = part.to; |
| 1891 | } |
| 1892 | } |
| 1893 | } |
| 1894 | |
| 1895 | function buildCollapsedSpan(builder, size, marker, ignoreWidget) { |
| 1896 | var widget = !ignoreWidget && marker.widgetNode; |