(cm, lineObj, _lineNo, preparedMeasure, order, x, y)
| 4238 | } |
| 4239 | |
| 4240 | function coordsBidiPartWrapped(cm, lineObj, _lineNo, preparedMeasure, order, x, y) { |
| 4241 | // In a wrapped line, rtl text on wrapping boundaries can do things |
| 4242 | // that don't correspond to the ordering in our `order` array at |
| 4243 | // all, so a binary search doesn't work, and we want to return a |
| 4244 | // part that only spans one line so that the binary search in |
| 4245 | // coordsCharInner is safe. As such, we first find the extent of the |
| 4246 | // wrapped line, and then do a flat search in which we discard any |
| 4247 | // spans that aren't on the line. |
| 4248 | var ref = wrappedLineExtent(cm, lineObj, preparedMeasure, y) |
| 4249 | var begin = ref.begin |
| 4250 | var end = ref.end |
| 4251 | if (/\s/.test(lineObj.text.charAt(end - 1))) { |
| 4252 | end-- |
| 4253 | } |
| 4254 | var part = null, |
| 4255 | closestDist = null |
| 4256 | for (var i = 0; i < order.length; i++) { |
| 4257 | var p = order[i] |
| 4258 | if (p.from >= end || p.to <= begin) { |
| 4259 | continue |
| 4260 | } |
| 4261 | var ltr = p.level != 1 |
| 4262 | var endX = measureCharPrepared(cm, preparedMeasure, ltr ? Math.min(end, p.to) - 1 : Math.max(begin, p.from)).right |
| 4263 | // Weigh against spans ending before this, so that they are only |
| 4264 | // picked if nothing ends after |
| 4265 | var dist = endX < x ? x - endX + 1e9 : endX - x |
| 4266 | if (!part || closestDist > dist) { |
| 4267 | part = p |
| 4268 | closestDist = dist |
| 4269 | } |
| 4270 | } |
| 4271 | if (!part) { |
| 4272 | part = order[order.length - 1] |
| 4273 | } |
| 4274 | // Clip the part to the wrapped line. |
| 4275 | if (part.from < begin) { |
| 4276 | part = { from: begin, to: part.to, level: part.level } |
| 4277 | } |
| 4278 | if (part.to > end) { |
| 4279 | part = { from: part.from, to: end, level: part.level } |
| 4280 | } |
| 4281 | return part |
| 4282 | } |
| 4283 | |
| 4284 | var measureText |
| 4285 | // Compute the default text height. |
nothing calls this directly
no test coverage detected